我目前正在研究一个应用程序,需要我有不同的UINavigationControllers - 所以我使用标签栏和企图使用UITabBar在它们之间进行交换,所以我有应用程序委托一些代码,像这样:UITabBar和超过1 UINavigationController
// Setting up the views for the tab controller
Friends *friends = [[[Friends alloc] initWithNibName:@"Friends" bundle:[NSBundle mainBundle]] autorelease];
WifiManager *wifi = [[[WifiManager alloc] initWithNibName:@"WifiManager" bundle:[NSBundle mainBundle]] autorelease];
UINavigationController *locationController = [[UINavigationController alloc] initWithRootViewController:wifi];
UINavigationController *friendsController = [[UINavigationController alloc] initWithRootViewController:friends];
//Set up the tab controller
tabBarController = [[UITabBarController alloc] init];
tabBarController.viewControllers =
[NSArray arrayWithObjects:locationController, friendsController, nil];
//Add the tab bar to the window
[window addSubview:tabBarController.view];
这将编译并加载了第一UINavigationController的,但是当我点击其他导航控制器上,我得到:
*** -[NSCFData tabBarItem]: unrecognized selector sent to instance 0x1152b0'
最奇怪的是我可以使用带有单个UINavigationController的标签控制器,一切正常,但是当我尝试添加第二个时,它失败了 - 有没有人有任何想法,我在这里做错了?
预先感谢您
詹姆斯
我刚刚在我自己的产品上试验过Kendall关于不自动释放的建议。我不认为这是你的问题,尽管它很容易测试。 – Amagrammer 2009-07-21 22:35:59
我确实有点朦胧 - 我忘记了包含 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView方法,它似乎与UINavigationController这是一个必需的方法,你会想到编译器会当它看到它不在那里时发出警告...... – 2009-07-22 08:10:23
我曾经与一位出色的C程序员一起工作,他在编译器上大喊几个小时来标记他完美的普通“for循环”: if(i = 0; i <5; ++ i){} 我们都昏暗偶尔。 – Amagrammer 2009-07-22 11:51:53