首页 > iOS7下UIPickerView代理方法不调用

iOS7下UIPickerView代理方法不调用

如题,项目本来是基于iOS8开发的,后使用 iOS7,iPhone5模拟器,发现运行,如下图:

最后经过排查 ,发现 UIPickerView的代理方法没有调用

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

    GUIHospitalModel *model = (GUIHospitalModel*)self.hosipitals[row];
    return model.hospital_name;
}

查询相关内容, 发现有人是因为谢了 viewForRow导致的不调用, 但是我代码中根本没有相关内容 .

相关代码:

@property(nonatomic,strong)UIPickerView * inputDataPickerView;


-(UIPickerView*)inputDataPickerView{
    if (!_inputDataPickerView) {
         _inputDataPickerView = [[UIPickerView alloc]init];
        _inputDataPickerView.delegate = self;
        _inputDataPickerView.dataSource = self;
        _inputDataPickerView.backgroundColor = [UIColor whiteColor];
        [_inputDataPickerView selectRow:0 inComponent:0 animated:YES];
    }
    return _inputDataPickerView;
}

 boundingHospitalTextField.inputView = self.inputDataPickerView;
    boundingHospitalTextField.inputAccessoryView = [self inputToolbar];

以上代码在iOS8模拟器中,正常运行. 所以实在没有头绪了 .

【热门文章】
【热门文章】