应用程序在启动时崩溃

时间:2011-12-28 15:37:00

标签: objective-c xcode sigabrt sigkill

我试图用Xcode创建一个iOS应用程序,直到现在一切都运行良好。 我在MainWindow.xib上有一个导航控制器,首先它加载了RootViewController NIB,但现在我将它改为main,因为我之前想要一个启动屏幕。但现在应用程序在启动时崩溃并出现错误“SIGABRT”。 线程1 0中止:

0x99771bdd  <+0167>  jmp    0x99771c0c <abort+214>
在11 UIApplicationMain中它是:

0x0036da9b  <+1175>  xor    %eax,%eax

并在main.m中:

  int retVal = UIApplicationMain(argc, argv, nil, nil);

它停止了。

新文件: StartScreen.h:

#import <UIKit/UIKit.h>
#import "RootViewController.h"

@interface StartScreen : UIViewController {
    RootViewController *rootViewController;

    IBOutlet UIButton *showList;
}

@property(nonatomic, retain) RootViewController *rootViewController;

@end

StartScreen.m:

#import "StartScreen.h"

@implementation StartScreen
@synthesize rootViewController;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    [showList addTarget:self action:@selector(showListButtonClicked) forControlEvents:UIControlEventTouchUpInside];
    return self;
}

-(void)showListButtonClicked {
    if(self.rootViewController == nil) {
        RootViewController *view2 = [[RootViewController alloc] initWithNibName:@"rootviewcontroller" bundle:nil];
        self.rootViewController = view2;
        [view2 release];
    }
    rootViewController.title = @"Test";
    [self.navigationController pushViewController:self.rootViewController animated:YES];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end

当启动图像出现时,应用程序会在1秒后直接关闭....

(另一个问题是,在此错误出现之前,关闭并在模拟器中重新启动应用程序后出现错误“SIGKILL”)

请帮助:)

1 个答案:

答案 0 :(得分:1)

检查.XIB文件中的连接。看起来StartScreen正在使用一个文件,其中“File Owner”设置为RootViewController。