我已经创建了一个UItabbarcontroller和2个视图与UITableViews只是使用代码(没有IB的东西),我想现在添加一个导航栏在顶部将包括添加和编辑按钮,但是,我似乎正在绊倒和鼓吹我的应用程序或将navgation控制器添加到第三个选项卡。以编程方式结合UITabController和UINavigation控制器http://t.co/R52RlUL以编程方式UITabController和UINavigation控制器
这里是我添加的标签栏和切换视图
FYI主代码 - 我使用XCode4
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.mainTabBar = [[UITabBarController alloc] init];
// create the 2 views
tableViewController* vc1 = [[tableViewController alloc] init];
tableViewController2* vc2 = [[tableViewController2 alloc] init];
// put them in an array
NSArray* controllers = [NSArray arrayWithObjects:vc1, vc2, nil];
// for the tab bar
mainTabBar.viewControllers = controllers;
// Add the tab bar controller's current view as a subview of the window
[self.window addSubview:self.mainTabBar.view];
// Override point for customization after application launch.
[self.window makeKeyAndVisible];
return YES;
}
由于以下但应用程式建立确定,但在第一导航控制器崩溃出 ' - (无效)的loadView { self.navigationItem.rightBarButtonItem = [[ALLOC的UIBarButtonItem] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit目标:自我行动:@selector(doSomething)]; } - (无效){DoSomething的 }' – adamprocter 2011-04-13 00:08:20
这是一个不同的问题。如果使用'loadView',则需要通过创建并设置其视图属性来初始化视图控制器。因为你的VC是UITableViewControllers,你还必须设置tableView属性。如果你认为你做的一切都正确,发布完整的'loadView'代码,我会看看。 – XJones 2011-04-13 03:09:04
我相信我已经设置了表格,因为它在添加navigationcontrollerv-代码之前工作,以遵循 – adamprocter 2011-04-13 08:09:25