代码之家  ›  专栏  ›  技术社区  ›  Edward Dale

将TTSearchBar与TTThumbsViewController一起使用

  •  0
  • Edward Dale  · 技术社区  · 16 年前

    TTSearchBar a以上 TTThumbsViewController . 我目前(失败的)尝试涉及到我自己 SearchViewController 继承自 TTViewController 并包含对 TTThumbsViewController tt搜索栏 . 在 loadView 方法,我将两者都实例化 TTThumbsViewController tt搜索栏 再加上它们(实际上,…the view SearchViewController 是推,也不是 也不是 tt搜索栏 将显示。

    #2601484 到了和问题相同的地方 #2614079 .

    我做错了吗?有没有更好的方法将搜索添加到 TTThumbsViewController ?

    1 回复  |  直到 9 年前
        1
  •  1
  •   John Wang    16 年前

    我不会这么做的。我会将TTThumbsViewController子类化,并将SearchBar添加到该子类中。TTThumbsViewController没有内置的搜索功能,我应该考虑创建它。

    另外,对于问题2,这通常是因为没有使用TTNavigator。TTThumbsViewController可能正在查找不存在的TTNavigator导航栏。您也可以在TTThumbsViewController子类中通过重写以下内容来解决此问题:

    - (void)updateTableLayout {
      self.tableView.contentInset = UIEdgeInsetsMake(TTBarsHeight()+4, 0, 0, 0);
      self.tableView.scrollIndicatorInsets = UIEdgeInsetsMake(TTBarsHeight(), 0, 0, 0);
    }
    
    // TTTableViewController
    - (CGRect)rectForOverlayView {
      return TTRectContract(CGRectOffset([super rectForOverlayView], 0, TTBarsHeight()-_tableView.top),
                            0, TTBarsHeight());
    }
    

    很可能是TTBarsHeight()引起了问题。我不得不为自己的一个项目做这个。