Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 目标C:使用代码将工具栏添加到UITableView(导航控制器内)_Objective C_Uitableview_Uinavigationcontroller_Uitoolbar - Fatal编程技术网

Objective c 目标C:使用代码将工具栏添加到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

我使用以下代码在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.view addSubview:toolbar];
但是,当我尝试切换回导航控制器的第一页时,页面底部的工具栏仍然显示。如何确保工具栏仅显示在UITable视图上,而不显示在导航控制器中的任何其他视图上

提前谢谢


在TableViewController中执行以下操作:

- (void)viewWillAppear:(BOOL)animated
{
    self.navigationController.toolbar.hidden = NO;
}

- (void)viewWillDisappear:(BOOL)animated
{
    self.navigationController.toolbar.hidden = YES;
}