我的iPhone应用程序非常简单,但它出错。我的应用程序代理打开此视图控制器:UIButton简单应用程序 - iPhone应用程序中的错误
#import "Launch.h"
@implementation Launch
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor redColor];
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = CGRectMake(100, 100, 100, 100);
[button setTitle:@"Hello" forState:UIControlStateNormal];
[button addTarget:self action:@selector(buttonPressed) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
}
-(void)buttonPressed {
NSLog(@"Button Pressed!");
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo {
//image.image = img;
[[picker parentViewController] dismissModalViewControllerAnimated:YES];
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
@end
这只是一个带按钮的红色屏幕。当我点击按钮时,应用程序出错,没有错误信息。为什么?
,这里是我的main.m方法,当程序发生错误时,它指向的“返回”行,并表示在一个线程的EXEC_BAD_ACCESS。
#import <UIKit/UIKit.h>
#import "testAppDelegate.h"
int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([testAppDelegate class]));
}
}
回溯没有有用的信息。它只是指向main.m类并没有有用的错误消息。 – CodeGuy 2012-01-16 02:32:05
在'buttonPressed'的'NSLog()'上设置一个断点。 – zaph 2012-01-16 02:37:26
就像我说的,没有错误信息。我在控制台上看到的最后一件事是:当前语言:auto;目前Objective-C的 (GDB) – CodeGuy 2012-01-16 02:37:36