Ios 返回UIApplicationMain(argc、argv、nil、NSStringFromClass([AppDelegate类]);线程1:SIGBART
每当我尝试运行我的应用程序时,都会出现此错误消息 viewController.hIos 返回UIApplicationMain(argc、argv、nil、NSStringFromClass([AppDelegate类]);线程1:SIGBART,ios,objective-c,iphone,xcode,simulator,Ios,Objective C,Iphone,Xcode,Simulator,每当我尝试运行我的应用程序时,都会出现此错误消息 viewController.h #import "ViewController.h" @interface ViewController () @end viewController.m @implementation ViewController - (void)viewDidLoad { // Do any additional setup after loading the view, typically from a
#import "ViewController.h"
@interface ViewController ()
@end
viewController.m
@implementation ViewController
- (void)viewDidLoad {
// Do any additional setup after loading the view, typically from a nib
[super viewDidLoad];
label.text = @"Number";
}
- (void)didReceiveMemoryWarning {
// Dispose of any resources that can be recreated
[super didReceiveMemoryWarning];
}
- (IBAction)numberButton {
int number;
number = arc4random() %100;
// Turns the integer (number) into a string
NSString *numberDisplay = [NSString stringWithFormat: @"%i", number];
// Because the text has to be a string, i.e. an NSString
label.text = numberDisplay;
}
- (IBAction)numButton {
int number;
number = arc4random() %100;
// Turns the integer (number) into a string
NSString *numberDisplay = [NSString stringWithFormat: @"%i", number];
// Because the text has to be a string, i.e. an NSString
label.text = numberDisplay;
}
- (IBAction)color {
int color;
color = rand() %4;
switch (color) {
case 0:
label.textColor = [UIColor redColor];
break;
case 1:
label.textColor = [UIColor purpleColor];
break;
case 2:
label.textColor = [UIColor blueColor];
break;
case 3:
label.textColor = [UIColor greenColor];
break;
default:
break;
}
}
- (IBAction)fontSize {
int fontSize;
fontSize = rand() %6;
switch (fontSize) {
case 0:
[label setFont: [UIFont fontWithName:@"" size:5]];
break;
case 1:
[label setFont: [UIFont fontWithName:@"" size: 15]];
break;
case 2:
[label setFont: [UIFont fontWithName:@"" size: 25]];
break;
case 3:
[label setFont: [UIFont fontWithName:@"" size: 35]];
break;
case 4:
[label setFont: [UIFont fontWithName:@"" size: 40]];
break;
case 5:
[label setFont: [UIFont fontWithName:@"" size: 45]];
break;
default:
break;
}
}
@end
My.h具有所有相同的操作。我已经反复检查了是否有拼写错误和/或连接错误。还有什么问题吗?取出
int number;
number = arc4random() %100;
在行动中。没有必要拥有它们。我在一个测试项目中尝试了您的代码,效果很好 我想也许你在这方面犯了一个错误。确认您的iAction连接没有冗余连接 这是我的代码(实际上我几乎没做任何更改):
您能在问题中更清楚地说明问题所在吗?请确保您的代码正确突出显示,并且我在两行之间找不到任何错误消息。设置一个异常断点,让我们知道您在哪一行崩溃。另外,发布完整的符号化堆栈跟踪。谢谢大家。很抱歉,我的代码格式不好,这是我第一次在网站上修复它。故事板中的视图控制器存在一个问题,按下黄色按钮后,我可以删除。感谢所有有用的评论和回答!下次我将更好地制定我的代码!谢谢这是如何解决OP的崩溃问题的?此外,OP正在设置一个文本标签,其结果为
number
,因此删除此代码实际上没有帮助。好吧,但这仍然不是答案。充其量应该是一个评论。
#import "ViewController.h"
@interface ViewController()
@property (nonatomic,weak) IBOutlet UILabel * label;
@end
@implementation ViewController
@synthesize label;
- (void)viewDidLoad {
// Do any additional setup after loading the view, typically from a nib
[super viewDidLoad];
label.text = @"Number";
}
- (void)didReceiveMemoryWarning {
// Dispose of any resources that can be recreated
[super didReceiveMemoryWarning];
}
- (IBAction)numberButton {
int number;
number = arc4random() %100;
// Turns the integer (number) into a string
NSString *numberDisplay = [NSString stringWithFormat: @"%i", number];
// Because the text has to be a string, i.e. an NSString
label.text = numberDisplay;
}
- (IBAction)numButton {
int number;
number = arc4random() %100;
// Turns the integer (number) into a string
NSString *numberDisplay = [NSString stringWithFormat: @"%i", number];
// Because the text has to be a string, i.e. an NSString
label.text = numberDisplay;
}
- (IBAction)color {
int color;
color = rand() %4;
switch (color) {
case 0:
label.textColor = [UIColor redColor];
break;
case 1:
label.textColor = [UIColor purpleColor];
break;
case 2:
label.textColor = [UIColor blueColor];
break;
case 3:
label.textColor = [UIColor greenColor];
break;
default:
break;
}
}
- (IBAction)fontSize {
int fontSize;
fontSize = rand() %6;
switch (fontSize) {
case 0:
[label setFont: [UIFont fontWithName:@"" size:5]];
break;
case 1:
[label setFont: [UIFont fontWithName:@"" size: 15]];
break;
case 2:
[label setFont: [UIFont fontWithName:@"" size: 25]];
break;
case 3:
[label setFont: [UIFont fontWithName:@"" size: 35]];
break;
case 4:
[label setFont: [UIFont fontWithName:@"" size: 40]];
break;
case 5:
[label setFont: [UIFont fontWithName:@"" size: 45]];
break;
default:
break;
}
}
@end