I have a UISearchBar in my navigation controller bar title view. I followed the first answer here How to add search bar in navigation bar for iphone?. This works for me but the dimensions of the search bar are hardcoded. How can I set the dimensions so that it looks nice on iPad and iPhone in both portrait and landscape mode?
This is the code in my search bar controller.
self.view = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 310.0, 44)];
self.view.autoresizingMask = 0;
_searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(-5.0, 0.0, 320.0, 44.0)];
_searchBar.autoresizingMask = UIViewAutoresizingFlexibleWidth;
_searchBar.delegate = self;
[self.view addSubview:_searchBar];
Then in my main viewController I have
self.navigationItem.titleView = _searchController.view;