tags:

views:

310

answers:

2

I would like to layout a TTSearchBar above above a TTThumbsViewController. My current (failing) attempt involves my own SearchViewController that inherits from TTViewController and contains a reference to a TTThumbsViewController and TTSearchBar. In the loadView method, I instantiate both TTThumbsViewController and TTSearchBar and add them (actually, ..the view property of the TTTVC) as subviews. When the SearchViewController is pushed, neither the TTThumbsViewController nor the TTSearchBar are displayed.

I've just follwed the instructions at question #2601484 and gotten to same place as question #2614079.

Am I going about this wrong? Is there a better way to add search to the TTThumbsViewController?

A: 

That's not how I'd go about it. I would subclass TTThumbsViewController and add the SearchBar to that subclass. There's no built-in search for TTThumbsViewController, I should look into creating that.

Also, for problem #2, that's usually a result of not using TTNavigator. The TTThumbsViewController is likely looking for the TTNavigator NavigationBar which doesn't exist. You can fix that in your TTThumbsViewController subclass as well by overriding things like:

- (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());
}

It's likely the TTBarsHeight() that's causing problems. I had to do this for one of my own projects.

John Wang
Thanks, both recommendations worked well. I had to adjust the insets by TTBarsHeight()-30 for one controller and TTBarsHeight()-60 for another, which seems pretty wonky. I'll have to look into if I'm doing anything strange. I am using TTNavigator, so I wouldn't think that'd be the problem.
scompt.com
A: 

So every thumbsviewcomtroller will have a ttsearchbar ?, is ther anyway to add searchbar just for one thumbsviewcontroller ?, or should ask this in new thread ?,

Thanks

damniatx