2011-05-12 169 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

你需要确保你已经实现了这个对象的委托方法。