应用程序在启动时崩溃

发布于 2024-12-22 23:59:07 字数 2160 浏览 3 评论 0原文

我正在尝试使用 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”)

请帮忙:)

Im trying to make an iOS App with Xcode, until now everything worked well.
I have an Navigation Controller on MainWindow.xib, first it loaded RootViewController NIB, but now I changed it to main because I want a launching screen before. But now the app crashes on startup with error "SIGABRT".
Thread 1 0 abort:

0x99771bdd  <+0167>  jmp    0x99771c0c <abort+214>

in 11 UIApplicationMain it is:

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

and in main.m:

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

where it stopped.

The new files:
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

The app directly shuts down after 1 second when the startup image appears....

(Another problem is, that before this error came the error "SIGKILL" appeared after closing and restarting the app in simulator)

Please help :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

糖粟与秋泊 2024-12-29 23:59:07

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

Check your connections in .XIB file. It looks like the StartScreen is using a file, where "File Owner" is set to RootViewController.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文