【发布时间】:2011-08-27 06:25:59
【问题描述】:
我有两个 nib 文件,从第一个 nib 文件中点击导航栏上的 Add 按钮时,我移到了另一个,在第二个视图上,我再次拥有带有 Save 按钮的导航栏,这是我在 viewDidLoad 事件中创建的,如下所示:
btnAdd = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:self.navigationItem action:@selector(saveRecord:)];
self.navigationItem.rightBarButtonItem = btnAdd;
self.navigationItem.title = @"Add Information";
[btnAdd release];
我还创建了方法saveRecord,如下所示
-(IBAction) saveRecord: (id)sender
{
NSLog(@"Save Button Tapped");
}
但是运行程序后出现以下错误说它找不到saveRecord方法..即使这个方法也没有用断点调用..
错误
2011-08-27 11:48:25.813 BarcodeDemo[1903:207] -[UINavigationItem saveRecord:]: unrecognized selector sent to instance 0x5558660
2011-08-27 11:48:25.817 BarcodeDemo[1903:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UINavigationItem saveRecord:]: unrecognized selector sent to instance 0x5558660'
*** Call stack at first throw:
(
0 CoreFoundation 0x012f95a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x0144d313 objc_exception_throw + 44
2 CoreFoundation 0x012fb0bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x0126a966 ___forwarding___ + 966
4 CoreFoundation 0x0126a522 _CF_forwarding_prep_0 + 50
5 UIKit 0x003744fd -[UIApplication sendAction:to:from:forEvent:] + 119
6 UIKit 0x00586cc3 -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 156
7 UIKit 0x003744fd -[UIApplication sendAction:to:from:forEvent:] + 119
8 UIKit 0x00404799 -[UIControl sendAction:to:forEvent:] + 67
9 UIKit 0x00406c2b -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
还有一些堆栈继续............
谁能帮帮我...我忘记了什么????????
【问题讨论】:
标签: iphone objective-c cocoa-touch uinavigationcontroller uinavigationbar