当按钮被点击时,我得到了一个IBACtion按钮,它打开了一个新的视图。当点击按钮时,我得到了EXC_BAD_ACCESS.i启用了NSZOMBIE,它显示了最后一行函数 - (无效)的主页可以帮助你我..下面是代码。EXC_BAD_ACESS当IBAction按钮被点击时
splashscreen.h
@interface SplashScreen : UIViewController {
HomePage *newEnterNameController;
}
@property(nonatomic,retain)HomePage *newEnterNameController;
@end
splashscreen.m
@implementation SplashScreen
@synthesize newEnterNameController;
-(void)homepage
{
self.newEnterNameController = [[HomePage new] initWithNibName:@"HomePage"bundle:
[NSBundle mainBundle]];
[newEnterNameController setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self presentModalViewController:self.newEnterNameController animated:YES];
}
- (void)dealloc {
[self.newEnterNameController release];
[super dealloc];
}
@end
在'homepage'方法的第一个语句中,您希望'alloc'而不是'new',并且您需要添加'autorelease'消息以避免泄漏,导致:'self.newEnterNameController = [[[HomePage alloc ] initWithNibName:@“HomePage”包: [NSBundle mainBundle]] autorelease];' – albertamg 2012-01-04 12:11:10
cud u给我一个小例子来说明如何做到这一点。 – kingston 2012-01-04 12:14:19
'[self presentModalViewController:self.snewEnterNameController animated:YES];'你能否修复这个错字('self。* s * new ...') – 2012-01-04 12:32:36