I have a bug in an app I'm working on regarding a UISearchBar.
Using the code:
int width = 250;
searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(768 - width - indent, companySelectionButton.frame.origin.y + (companySelectionButton.frame.size.height - 44)/2, width, 44)];
[searchBar setAutoresizingMask: UIViewAutoresizingFlexibleLeftMargin];
[searchBar setPlaceholder:[Globals localisedString:@"Search by Code or Name"]];
[searchBar setAutocorrectionType:UITextAutocorrectionTypeNo];
[searchBar setDelegate:self];
[self.view addSubview:searchBar];
[searchBar release];
[[searchBar.subviews objectAtIndex:0] removeFromSuperview];
The search bar is in the position I want in both orientations, but it won't respond to taps in landscape and become first responder/show the keyboard.
I've tried commenting out the following lines to see if it helps but it doesn't fix it:
[searchBar setAutoresizingMask: UIViewAutoresizingFlexibleLeftMargin];
[[searchBar.subviews objectAtIndex:0] removeFromSuperview];
Anyone else had a similar issue?
Thanks in advance :)
EDIT
After commenting out [searchBar setDelegate:nil]; the search bar is able to become first responder in all orientations. But of course I need a delegate to be able to use the searchbar! Any ideas??? Will continue to have a play, perhaps I'm missing some delegate method?
Sorry everyone, I discovered that I was accidentally doing something strange in my searchBarTextDidBeginEditing delegate method that resigned the searchbar as first responder if the device was in landscape.
This question is of no use to any one, should I delete it?