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;
}
谢谢你们!
不工作......我将创建导航控制器,我的第一个视图控制器内。 –
您的部分“错误指定”可能是“访问不良”错误。这意味着你可以从内存区域写入或读取你不想要的内容。不过,仔细查看代码,看看其他可能出错的东西 –
检查我的编辑。你得到一个错误,我有一个问题是视图不会加载。那就是为什么隐藏=不存在 –