iphone - UIPickerView 导致应用程序崩溃

标签 iphone uitableview uinavigationcontroller uipickerview

我有两种看法。 第一个:第一个 View Controller 第二:SecondViewController

FirstView Controller 是我的 UINavigationController 的根 Controller ,里面有一个表。单击单元格时, View 将导航到 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,并为委托(delegate)和数据源选择了文件所有者。但是,当 ViewDidLoad 方法在 SecondViewController 中结束时,应用程序崩溃并显示:

Program received signal: SIGABRT

第二行:

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

我应该做什么来防止这种崩溃并让 View 加载 uipickerview?

编辑:

当我从 Interface Builder 中删除 UIPickerView 时,应用程序可以正常运行。我想我在将 UIPickerView 放入 UIView 时遇到了一些问题,但我无法处理,新手很难。

最佳答案

您需要确保已实现该对象的委托(delegate)方法。

关于iphone - UIPickerView 导致应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5978341/

相关文章:

ios - 如何隐藏委托(delegate)中的导航栏

ios - 在 UIPageViewController 中显示不同类型的内容

iphone - 非常非常持久的无效权利错误

swift - 两个不同单元格的 TableView 相同的 cellForRowAt 用法

swift - 将多个类型的 TableViewCells 放在同一个 TableView 中

ios - 在 loadView 期间或之前获取 UINavigationController 的内部 contentView 的 CGRect 框架

ios - 如何在iOS应用程序中转到 "Home-page"?

iphone - Xcode 4.2 首选项 "Support Wirelessly Connected Devices"有什么作用?

iphone - 当有多个 View 时隐藏界面生成器中的 View

swift - 快速在 UITableView 中创建下拉菜单