Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/96.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 为什么这些视图从未在UIPickerView中为委托viewForRow重用?_Ios_Uiview_Uipickerview - Fatal编程技术网

Ios 为什么这些视图从未在UIPickerView中为委托viewForRow重用?

Ios 为什么这些视图从未在UIPickerView中为委托viewForRow重用?,ios,uiview,uipickerview,Ios,Uiview,Uipickerview,我正在尝试使用自定义视图实现UIPickerView。奇怪的是,当我在picker视图中滚动项目时,重用视图总是为nil - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view { UILabel* lab

我正在尝试使用自定义视图实现UIPickerView。奇怪的是,当我在picker视图中滚动项目时,重用视图总是为nil

- (UIView *)pickerView:(UIPickerView *)pickerView
            viewForRow:(NSInteger)row
          forComponent:(NSInteger)component
           reusingView:(UIView *)view
{ 
    UILabel* label = (UILabel *)view;
    if (label==nil) {
        CGRect frame = CGRectMake(0, 0, 100, 22);
        label = [[UILabel alloc] initWithFrame:frame];
        view = label;
    }
    else {            
        NSLog(@"This is never called");
    }
    label.text = [NSString stringWithFormat:@"%d",row];

    return view;
}

我猜您正在使用iOS7.0,这是一个bug,请看这里,感谢您指出这个问题。看起来我需要实现自己的视图回收代码。