我是新来的objective-c,我目前正在开发iOS应用程序。 我有一个按钮,我打电话给SettingsButton,这是一个自定义的UIView对象。 当我按下此按钮时,调用FileOwner“ViewController.m”的Touch Up Inside处理程序,稍后将在NavigationController上推送ViewController。 但是,该应用程序与SIGABRT或EXC_BAD_ACCESS崩溃。 这是因为我在AppDelegate.m中插入了带有NavigationController的代码 有没有想法?按下带导航控制器的按钮时iOS应用程序崩溃
AppDelegate.m:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
UIViewController *vc;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
vc = [[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil];
} else {
vc = [[ViewController alloc] initWithNibName:@"ViewController_iPad" bundle:nil];
}
UINavigationController* navController =
[[UINavigationController alloc] initWithRootViewController:vc];
navController.navigationBarHidden = true;
[self.window addSubview:navController.view];
[self.window makeKeyAndVisible];
return YES;
}
ViewController.m:
- (IBAction)SettingsPressed:(id)sender {
NSLog(@"SettingsPressed!");
}
要明确:我的本意是只改变视图按下SettingsButton并具有返回 - 当按钮返回。但该应用程序已经崩溃与空事件处理程序。当SIGABRT发生
ERRORMESSAGE:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString SettingsPressed:]: unrecognized selector sent to instance 0x7a06fc0'
你可以把线路崩溃吗? – 2012-03-02 12:42:58
我刚刚从控制台添加了发生的errormessage。希望这就是你的意思。 – Marv 2012-03-02 13:03:09
好吧,我越来越近了,我可以看到一段代码,你打电话给SettingsPressed – 2012-03-02 13:04:09