ios - InputView 在 UICollectionView 内的 TextFields 中不起作用

标签 ios objective-c

在每个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/

相关文章:

ios - xcode 6.1 发现重复的本地化资源 "/Localizable.strings"

objective-c - 在 iPad 中解析 XML 文件时如何处理 CDATA 标签

iphone - 如何从 NSArray 中获取 NSNumber 的总和?

objective-c - 如何使用 cocoa 进度条?

ios - 如何将 CVImageBuffer 转换为 UIImage?

android - App Store 审核团队报告使用 Firebase 存储时出现 'Connection refused' 错误,阻止图像加载

ios - Swift - 从完成 block 中解散 View Controller

ios - 更新 NSArray 中特定索引处的值

objective-c - 奇怪的 XCode 4.2 和核心数据行为

objective-c - sizeWithFont 在 UITextField 中返回错误的高度