UIPickerView内容未在iOS7中显示

时间:2014-01-10 23:15:58

标签: ios7 uipickerview

更新到Xcode 5并更新我的应用程序以使用iOS7后,UIPickerView将不会显示我的阵列的内容并显示为空白。将以下代码放入后,数组将显示在UIPickerView中,但在几次旋转后会崩溃:

- (void)viewDidLoad {
    [super viewDidLoad];
    NSArray *array = [[NSArray alloc] initWithObjects:@" ",@" ",@" ",@" ",@" ",@" ",@" ",@" ",@" ",@" ",@" ", nil];
    self.contentArray = array;   
}

以下是UIPickerView委托方法:

    #pragma mark - pickerview methods
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
    return 1;
}

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:      (NSInteger)component {
    return contentArray.count;
}


- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {

    return [self.contentArray objectAtIndex:row];

}    

我知道这是错的,但是作为新手开发者无法做到这一点。有没有人有什么建议?提前感谢您的意见,我已经工作了3天,无法继续前进。

0 个答案:

没有答案