大佬教程收集整理的这篇文章主要介绍了iphone – 如何以编程方式创建tabbar并在其上添加按钮,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
Apple的立场是这样的:
这并不是说你不能以不同的方式做事……你的主要问题是你已经在应用程序中放置了一个Nav Controller,并且你想以编程方式创建标签栏控制器.因此,我可以看到这一点的唯一方法是,您不介意每次更改导航控制器中的屏幕时标签栏控制器是否更改.有些应用以这种方式工作.大多数人没有.
如果我的上述假设是正确的,我建议您重新考虑您的代码,看看您是否想要进行这种开发.如果是这样,您可以轻松创建标签栏控制器并将其附加到当前视图中.
以下是我用于为我的某个应用创建设置的代码:
// set up a local nav controller which we will reuse for each view controller UINavigationController *localNavigationController; // create tab bar controller and array to hold the view controllers UITabBarController *tabBarController = [[UITabBarController alloc] init]; NSMutableArray *localControllersArray = [[NSMutableArray alloc] initWithCapacity:1]; // setup the first view controller (Root view controller) RootViewController *myViewController; myViewController = [[RootViewController alloc] initWithTabBar]; // create the nav controller and add the root view controller as its first view localNavigationController = [[UINavigationController alloc] initWithRootViewController:myViewController]; localNavigationController.navigationBar.barStyle = UIBarStyleBlack; localNavigationController.delegate = self; [localControllersArray addObject:localNavigationController]; // release since we are done with this for Now [localNavigationController release]; [myViewController release]; tabBarController.viewControllers = localControllersArray; tabBarController.moreNavigationController.navigationBar.barStyle = UIBarStyleBlack; tabBarController.delegate = self; tabBarController.moreNavigationController.delegate = self; // release the array because the tab bar controller Now has it [localControllersArray release]; self.tabBarController.SELEctedIndex = 0; // add the tabBarController as a subview in the window [window addSubview:tabBarController.view]; // need this last line to display the window (and tab bar controller) [window makeKeyAndVisible];
希望这可以帮助.
以上是大佬教程为你收集整理的iphone – 如何以编程方式创建tabbar并在其上添加按钮全部内容,希望文章能够帮你解决iphone – 如何以编程方式创建tabbar并在其上添加按钮所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。