如何在 iPhone 的自定义导航栏中创建导航栏项目?
我创建了一个自定义视图,并添加了一个 Web 视图作为该自定义视图的子视图。我以编程方式创建了一个导航栏。现在我想在该视图中创建一个左或右导航栏按钮。
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
如何在自定义导航栏中创建导航栏项目?我想删除自定义视图。所以请帮助我!
谢谢。
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!
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在您的导航栏引用中,您可以调用这两种方法:
在您的自定义视图控制器类中编写如下内容:
因此您可以编写如下内容:
On your navigationbar reference you could invoke the two methods:
In your custom view controller class write something like this:
So you could write something like this:
rightBarButton
是为UINavigationItem
定义的。请参阅UINavigationItem< 的文档/code>
和
UINavigationBar
(特别是向导航栏添加内容)。使用的方法是
- (void)pushNavigationItem:(UINavigationItem *)itemAnimated:(BOOL)animated
rightBarButton
is defined forUINavigationItem
. See the documentation for theUINavigationItem
and for theUINavigationBar
(Specially Adding Content to a Navigation Bar).The method to use is
- (void)pushNavigationItem:(UINavigationItem *)item animated:(BOOL)animated
请参阅 http://developer.apple.com/ library/ios/documentation/uikit/reference/UINavigationItem_Class/Reference/UINavigationItem.html
您将调用 self.navigationItem 的方法。
See http://developer.apple.com/library/ios/documentation/uikit/reference/UINavigationItem_Class/Reference/UINavigationItem.html
You would invoke methods to self.navigationItem.