我有兩個筆尖文件,並從第一個筆尖文件,同時攻絲Add
按鈕導航欄上我搬到另一個和第二個視圖我再次有導航欄Save
按鈕,我在viewDidLoad事件中創建如下:UINavigationItem - 無法識別選擇器
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方法之後。即使這個米ethod也沒有用的斷點稱爲..
錯誤
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
和一些堆棧的推移..........
任何一個可以幫助我.. 。我忘了什麼????????