2011-05-12 172 views
2

我有兩種看法。 FirstView:FirstViewController Second:SecondViewControllerUIPickerView導致應用程序崩潰

FirstView Controller是我的UINavigationController的根控制器,我有一個表格。單擊單元格時,視圖將導航到SecondViewController。在SecondViewController中,我試圖放置一個UIPickerView。

在SecondViewController.h,我有:

@interface SearchOptionController : UIViewController { 

    IBOutlet UIPickerView *pickerView; 
    NSMutableArray *optionArray; 

} 


@property (nonatomic, retain) IBOutlet UIPickerView *pickerView; 
@property (nonatomic, retain) NSMutableArray *optionArray; 

@end 

在SecondViewController.m我有:

@synthesize pickerView; 

和所有pickerview方法。

我從界面構建器添加了UIPickerView,併爲委託和數據源選擇了文件所有者。但是,當viewDidLoad方法中SecondViewController結束應用程序崩潰說:

程序接收到的信號:SIGABRT

在第二行:

int main(int argc, char *argv[]) 
{ 
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 
    int retVal = UIApplicationMain(argc, argv, nil, nil); 
    [pool release]; 
    return retVal; 
} 

那我該怎麼做才能防止這次崩潰並讓視圖用uipickerview加載?

編輯:

當我從Interface Builder中取出UIPickerView,應用程序運行正常。我想我把UIPickerView放在UIView裏面有一些問題,但我無法處理,被新手困難。

+0

當應用程序崩潰時,您通常會在控制檯中看到錯誤描述 - 它是什麼? – Vladimir 2011-05-12 13:03:31

+0

您是否實現了選取器的委託方法? – dks1725 2011-05-12 13:04:22

+0

2011-05-12 16:04:55.108 Senior5 [1006:207] - [SearchOptionController numberOfComponentsInPickerView:]:無法識別的選擇器發送到實例0x4e33410 2011-05-12 16:04:55.110 Senior5 [1006:207] ***終止應用程序由於未捕獲的異常 'NSInvalidArgumentException',原因: ' - [SearchOptionController numberOfComponentsInPickerView:]:無法識別的選擇發送到實例0x4e33410' – aeciftci 2011-05-12 13:05:54

回答

2

你需要確保你已經實現了這個對象的委託方法。