【问题标题】:The last few search results are hidden behind keyboard最后几个搜索结果隐藏在键盘后面
【发布时间】:2012-03-08 10:19:22
【问题描述】:

我有一个位于 tableview 上方的搜索栏。搜索功能很好用。

问题是当搜索结果超过 4 个时,其他结果隐藏在弹出的键盘后面。有没有一种简单的方法来调整仅在搜索时包含结果的 tableview 的大小?

【问题讨论】:

    标签: xcode uitableview uisearchbar


    【解决方案1】:

    我想做的是在键盘处于活动状态时调整 tableview 的大小。操作方法如下:

    CGFloat height = (self.tableView.frame.size.height/2);
    CGFloat width = self.tableView.frame.size.width;
    
    CGRect halfFrame = CGRectMake(0, 0, width, height);
    tableView.frame = halfFrame;
    

    移除键盘后,使用此代码将 tableview 调整为正常大小:

    CGFloat height = (self.tableView.frame.size.height*2);
    CGFloat width = self.tableView.frame.size.width;
    
    CGRect fullFrame = CGRectMake(0, 0, width, height);
    tableView.frame = fullFrame;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-05-01
      • 2011-09-22
      • 1970-01-01
      • 2022-01-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多