當按鈕被點擊時,我得到了一個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