【问题标题】:UITableView as inputAccessoryView has height of zeroUITableView 作为 inputAccessoryView 的高度为零
【发布时间】:2015-03-20 03:02:37
【问题描述】:

我有两个表格视图,在我的项目中用作输入附件视图。一个是以编程方式创建的,并且显示得非常好。第二个是自定义表格视图,其中包含在情节提要中制作的自定义单元格,并存储为视图控制器的属性作为强引用。

@property UITableView *firstTable; @property (strong, nonatomic) IBOutlet UITableView *secondTable;

它们都是在viewDidLoad中发起的,如下:

self.firstTable = [[UITableView alloc] initWithFrame:
                        CGRectMake(0, 0, self.view.bounds.size.width, 100) style:UITableViewStylePlain];
self.firstTable.delegate = self;
self.firstTable.dataSource = self;
self.firstTable.scrollEnabled = YES;
self.firstTable.rowHeight = 30;
self.firstTable.backgroundColor = [[SwagCommonFunctions alloc] colorWithHexString:@"f4ecea"];

self.secondTable.frame = CGRectMake(0, 0, self.view.bounds.size.width, 100);

它们在另一个函数中被设置为输入附件视图

[textView setInputAccessoryView:self.firstTableView];
    [textView reloadInputViews];

[textView setInputAccessoryView:self.secondTableView];
    [textView reloadInputViews];

firstTable 完美运行。 secondTable 永远不会加载,因为在 cellForRowAtIndexPath 时帧高度为零。如果在 numberOfRowsInSection 中手动将框架高度设置为 100(宽度为全屏),原点为 (0,0),则 secondTable 会按预期显示正确的数据,但框架会遮盖整个键盘,而不是停留在正常的 inputAccessoryView地点。

如何设置 secondTable 的框架以使其正常运行?

【问题讨论】:

    标签: uitableview ios8 inputaccessoryview


    【解决方案1】:
    self.secondTable.autoresizingMask = UIViewAutoresizingNone;
    

    【讨论】:

      猜你喜欢
      • 2015-03-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-23
      • 2011-05-06
      • 1970-01-01
      • 2015-10-27
      • 2015-02-09
      相关资源
      最近更新 更多