应用程序在启动时崩溃
我正在尝试使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查 .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.