如何在iPhone的自定义导航栏中创建导航栏项目? [英] How to create navigation bar item in the custom Navigation Bar in iPhone?

查看:95
本文介绍了如何在iPhone的自定义导航栏中创建导航栏项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个自定义视图,并添加了一个Web视图作为该自定义视图的子视图.我已经以编程方式创建了一个导航栏.现在,我想在该视图中创建一个向左或向右导航栏按钮.

I have created one custom view and added a web view as subview of that custom view. And i have created one navigation bar in programmatically. Now i want to create one Left or Right navigation bar buttons in that view.

navigBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];

navigBar.tintColor = [UIColor blackColor];

[self.view addSubview:navigBar];

UIBarButtonItem *homeButton = [[UIBarButtonItem alloc] initWithTitle:@"Home" style:UIBarButtonSystemItemAction target:self action:@selector(homeButtonAction)];

navigBar.rightBarButtonItem = homeButton; // it's not supports

如何在自定义导航栏中创建导航栏项目?我想删除自定义视图.所以请帮帮我!

How can i create navigation bar item in the custom navigation bar?, i want to remove the custom view. So please Help me out!

谢谢.

推荐答案

在导航栏引用上,您可以调用以下两种方法:

On your navigationbar reference you could invoke the two methods:

- (void)pushNavigationItem:(UINavigationItem *)item animated:(BOOL)animated
- (UINavigationItem *)popNavigationItemAnimated:(BOOL)animated

在您的自定义视图控制器类中,编写如下内容:

In your custom view controller class write something like this:

self.navigationItem.leftBarButtonItem = yourButton;
self.navigationItem.rightBarButtonItem = yourSecondButton;

所以您可以这样写:

[myNavBarReference pushNavigationItem:self.navigationItem animated:NO];

这篇关于如何在iPhone的自定义导航栏中创建导航栏项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆