0

Quite simply, I'm implementing UISearchBarDelegate, but in landscape mode it looks wrong. The search bar doesn't stretch all the way right. Is UISearchBarDelegate not suppose to be used in landscape or is there a solution?

Andy A
  • 4,191
  • 7
  • 38
  • 56

1 Answers1

1

It's highly unlikely that the problem is with the delegate. It's probably that the autoresizingMask isn't set properly. It should be,

searchBar.autoresizingMark = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin;
Deepak Danduprolu
  • 44,595
  • 12
  • 101
  • 105
  • Thanks that worked! (Well, the method should be autoresizingMask, rather than autoresizingMake, but close enough!) However, I know notice that the UITableView also isn't stretched, and it doesn't work if I try myTableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin; Any ideas? – Andy A Jun 15 '11 at 08:06
  • use `UIViewAutoresizingFlexibleTopMargin` instead of `UIViewAutoresizingFlexibleBottomMargin`. – Deepak Danduprolu Jun 15 '11 at 08:08
  • Thanks for the suggestion but that did not work. Mmm, I'm surprised I'm finding this one tricky. – Andy A Jun 15 '11 at 08:17
  • `myTableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleHeight;` – Deepak Danduprolu Jun 15 '11 at 08:19
  • Ah, it works now! The problem (with the table) was me being totally stupid and trying autoresize the table before calling 'initWithFrame'! – Andy A Jun 15 '11 at 08:30
  • I have recently brought in landscape mode, and on landscape my search bar doesn't quite stretch all the way right. Infact, if u then rotate to portrait the same problem exists. However, if you start in portrait mode, its fine (even if you rotate) – Andy A Jun 24 '11 at 12:03
  • The answer to this latest issue is http://stackoverflow.com/questions/6466893/uisearchbar-width-wrong-in-landscape – Andy A Jun 27 '11 at 09:51