Objective c 目标C:使用代码将工具栏添加到UITableView(导航控制器内)
我使用以下代码在UITableView的底部添加了一个工具栏:Objective c 目标C:使用代码将工具栏添加到UITableView(导航控制器内),objective-c,uitableview,uinavigationcontroller,uitoolbar,Objective C,Uitableview,Uinavigationcontroller,Uitoolbar,我使用以下代码在UITableView的底部添加了一个工具栏: 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.v
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视图上,而不显示在导航控制器中的任何其他视图上
提前谢谢
在TableViewController中执行以下操作:
- (void)viewWillAppear:(BOOL)animated
{
self.navigationController.toolbar.hidden = NO;
}
- (void)viewWillDisappear:(BOOL)animated
{
self.navigationController.toolbar.hidden = YES;
}