gpt4 book ai didi

ios - 无法将 UIBarButtonItem 添加到 UITabBarController 内的 navigationController

转载 作者:可可西里 更新时间:2023-11-01 06:23:11 24 4
gpt4 key购买 nike

ViewController *VC = [[ViewController alloc] initWithNibName:nil bundle:nil];
UINavigationController *NavCon = [[UINavigationController alloc] initWithRootViewController:VC];
NavCon.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Close" style:UIBarButtonItemStyleBordered target:self action:@selector(showall)];
[self.myTabBarController setViewControllers:@[NavCon]];

为什么它没有将 UIBarButtonItem 添加到我的导航 Controller ?

最佳答案

首先删除/注释代码行

NavCon.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Close" style:UIBarButtonItemStyleBordered target:self action:@selector(showall)];

然后将此代码放入 navController 的 viewController 的 viewDidLoad 方法中。

self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Close" style:UIBarButtonItemStyleBordered target:self action:@selector(showall)];

关于ios - 无法将 UIBarButtonItem 添加到 UITabBarController 内的 navigationController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22405258/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com