IOS 小白求大神帮忙,为什么返回按钮会报exc_bad_access
如题,之前学过ios, 很久没用都忘了QAQ.
一个很简单的程序,可是跳转后不可以回去了,
跳转的代码
- (IBAction)YukiBanButtonPress:(id)sender {
[[[UIApplication sharedApplication] keyWindow] endEditing:YES];
AboutUs*AboutusController= [[[AboutUs alloc] initWithNibName:@"AboutUs" bundle:nil] autorelease];
[AboutusController setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
[self.view addSubview:AboutusController.view];
[self.navigationController pushViewController:AboutusController animated:YES];
[AboutusController.view setFrame:self.view.bounds];
[AboutusController setYukiBan];
[AboutusController.navigationItem setTitle:@"YUKI BAN"];
}
返回按钮的代码
UINavigationItem*item= [NavigationBar.items objectAtIndex:0];
UINavigationItem *back = [[UINavigationItem alloc] initWithTitle:@"Back"];
NSArray *items = [[NSArray alloc] initWithObjects:back,item,nil];
[NavigationBar setItems:items];
[back release];
[items release];
[NavigationBar setDelegate:self];
我用僵尸测试了,显示是之前跳转的方法有问题,可是怎么也看不出到底哪里出问题的
用的是ios7,难道是特殊功能么TAT。
谢谢各位,小白谢谢大家了
[解决办法]
代码有很大的问题。
如果是使用push的方式来导航视图,那么你的这句话是没事找事的
[self.view addSubview:AboutusController.view];
- (IBAction)YukiBanButtonPress:(id)sender {
[[[UIApplication sharedApplication] keyWindow] endEditing:YES];
AboutUs *AboutusController= [[[AboutUs alloc] initWithNibName:@"AboutUs" bundle:nil] autorelease];
[self.navigationController pushViewController:AboutusController animated:YES];
}