0
我試圖與的TabBar控制器和導航控制器的應用程序。 但我得到一些問題...當我嘗試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;
}
謝謝你們!
不工作......我將創建導航控制器,我的第一個視圖控制器內。 –
您的部分「錯誤指定」可能是「訪問不良」錯誤。這意味着你可以從內存區域寫入或讀取你不想要的內容。不過,仔細查看代碼,看看其他可能出錯的東西 –
檢查我的編輯。你得到一個錯誤,我有一個問題是視圖不會加載。那就是爲什麼隱藏=不存在 –