大家好,
我试图用标签栏控制器和导航控制器制作一个应用程序。但是我遇到了一些问题......当我尝试在我的第二个视图上 popViewController 时,应用程序崩溃了。有人知道发生了什么吗?
我的代表:
// -- PranchetaAppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.tabBarController = [[UITabBarController alloc] init];
NSMutableArray *localControllersArray = [[NSMutableArray alloc] initWithCapacity:1];
PlayersViewController* playersViewController = [[PlayersViewController alloc] initWithTabBar];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:playersViewController];
[localControllersArray addObject:self.navigationController];
[self.navigationController release];
self.tabBarController.viewControllers = localControllersArray;
[self.window addSubview:self.tabBarController.view];
[self.window makeKeyAndVisible];
[self.navigationController release];
[localControllersArray release];
return YES;
}
我的第一视角:
// -- PlayersViewsController.m
- (id)initWithTabBar {
if (self)
{
self.title = @"Players";
self.tabBarItem.image = [UIImage imageNamed:@"PlayersTabBarIcon.png"];
CustomNavigationBarButton *addButtonView = [[CustomNavigationBarButton alloc] initWithImage:@"AddButton.png" withSelected:@"AddButtonSelected.png"];
[addButtonView addTarget:self action:@selector(gotoCreatePlayers) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithCustomView:addButtonView];
self.navigationItem.rightBarButtonItem = addButton;
[addButton release];
[addButtonView release];
}
return self;
}
- (void)gotoCreatePlayers {
CreatePlayersViewController *createPlayer = [CreatePlayersViewController new];
[self.navigationController pushViewController:createPlayer animated:YES];
[createPlayer release];
}
当我推动我的第二个视图时,我尝试返回导航。但是应用崩溃...
指定错误:
// -- main.m
int main(int argc, char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;
}
多谢你们!