在每个CollectionViewCells
中,我添加了UITextField
,它需要从选择器 View 中获取输入。
因此,我将 inputView 分配为 CellForRowAtIndexPath
内的 pickerView。
当我运行代码时,输入 View 部分为空。没有任何选择器 View 。
I realize the datasource methods are not getting invoked.
percentagePicker
在我的 ViewController 上创建了 socket
这是我的 cellForRowAtIndexPath 方法
cell.cropPercent.text = [NSString stringWithFormat:@"%@",cropPercentagesList[indexPath.row];
UIPickerView *pikerView = _percentagePicker;
[_percentagePicker removeFromSuperview];
pikerView.delegate =self;
pikerView.dataSource = self;
cell.cropPercent.textColor = [UIColor redColor];
cell.cropPercent.inputView = pikerView;
最佳答案
与其创建 UIPickerView 的导出并将其分配给 pickerView 以显示为 inputView,不如尝试下面的代码。
UIPickerView *pikerView = [[UIPickerView alloc]init];
pikerView.delegate =self;
pikerView.dataSource = self;
cell.cropPercent.textColor = [UIColor redColor];
cell.cropPercent.inputView = pikerView;
关于ios - InputView 在 UICollectionView 内的 TextFields 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45182788/