【发布时间】:2011-09-16 05:46:28
【问题描述】:
好的,我有以下内容:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
MainViewController * tabBarController = [[MainViewController alloc] init];
[self.window addSubview:tabBarController.view];
[self.window makeKeyAndVisible];
[tabBarController release];
[application registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge|
UIRemoteNotificationTypeAlert|
UIRemoteNotificationTypeSound];
return YES;
}
这里,MainViewController 只是 UITabBarController 的一个子类,在 MainViewController 的 viewDidLoad 里面我有:
- (void)viewDidLoad
{
[super viewDidLoad];
NSMutableArray *localControllersArray = [[NSMutableArray alloc] initWithCapacity:3];
MapViewController * map = [[MapViewController alloc] init];
[localControllersArray addObject:map];
//[localNavigationController release];
[map release];
ListViewController * voteSpot = [[ListViewController alloc] initWithTabBar];
[localControllersArray addObject:voteSpot];
//[localNavigationController release];
[voteSpot release];
ProfileViewController * profile = [[ProfileViewController alloc] initWithTabBar];
[localControllersArray addObject:profile];
//[localNavigationController release];
[profile release];
self.viewControllers = localControllersArray;
[localControllersArray release];
}
现在我能看到的只是:
知道为什么是白屏吗?
这是我的 initWithTabBar 示例:
-(id) initWithTabBar {
if ([self init]) {
self.navigationItem.title=@"Map";
}
return self;
}
暂时忽略底部的标签栏(中间缺少一个),这正是我想要的。我感到困惑的是与每个标签关联的 viewController,它上面什么都没有,而实际上 MapViewController 有一个 MapView它。当我单击任何选项卡时,它将在int retVal = UIApplicationMain(...) 崩溃(程序接收信号:EXC_BAD_ACCESS)
更新:
如果你想调试它,我已经在git hub 上传了一个示例代码,你可以在那里下载整个项目(这是一个简单的测试项目,我保证)
【问题讨论】:
标签: iphone objective-c ipad uiviewcontroller