目标 C:使用代码将工具栏添加到 UITableView(在导航控制器中) [英] Objective C: Using code to add a toolbar to a UITableView (within a Navigation Controller)
本文介绍了目标 C:使用代码将工具栏添加到 UITableView(在导航控制器中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我设法使用以下代码在 UITableView 底部添加了一个工具栏:
I managed to add a toolbar at the bottom of my UITableView using the code below:
toolbar = [[UIToolbar alloc] init];
toolbar.barStyle = UIBarStyleDefault;
toolbar.frame = CGRectMake(0, 436, 320, 50);
//Set the toolbar to fit the width of the app.
[toolbar sizeToFit];
[self.navigationController.view addSubview:toolbar];
但是当我尝试切换回导航控制器的第一页时,页面底部的工具栏仍然显示.如何确保工具栏仅显示在 UITable 视图上,而不显示在导航控制器中的任何其他视图上?
However when I try to switch back to the first page of the navigation controller, the toolbar at the bottom of the page is still displayed. How can I ensure that the toolbar is only shown on the UITable View and not any other views in the navigation controller?
提前致谢.
镇
推荐答案
在你的 TableViewController 中实现:
In your TableViewController implement:
- (void)viewWillAppear:(BOOL)animated
{
self.navigationController.toolbar.hidden = NO;
}
- (void)viewWillDisappear:(BOOL)animated
{
self.navigationController.toolbar.hidden = YES;
}
这篇关于目标 C:使用代码将工具栏添加到 UITableView(在导航控制器中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文