我的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