【发布时间】:2011-08-24 02:45:47
【问题描述】:
我有两种观点。 第一个:FirstViewController 第二:SecondViewController
FirstView 控制器是我的 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 时遇到了一些问题,但我无法处理,作为新手很难.s
【问题讨论】:
-
当应用程序崩溃时,您通常会在控制台中看到错误描述 - 这是什么?
-
你实现了picker的委托方法吗?
-
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”
-
好的,我发现了问题 - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView 方法丢失了。谢谢你的回答。
标签: iphone uitableview uinavigationcontroller uipickerview