I'm having some trouble implementing a design for an app I'm building. The design shows a UIActionSheet menu with a search bar at the top. When someone enters in text into the search bar, the menu goes away and is replaced by a table view containing search results. (The search results display in a similar style to when you slide all the way left on your home screen to search on your iPhone / iPod)
Here's essentially what I'm trying to pull off:
Here's the code I have:
// build menu
UIActionSheet* menu = [[UIActionSheet alloc] initWithTitle:@""
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:@"Button 1",@"Button 2",@"Button 3",nil];
[menu showInView:self.view];
UISearchBar *searcher = [[UISearchBar alloc] initWithFrame: CGRectMake (0, -216, 320, 44)];
searcher.delegate = self;
// use transparent background
[[searcher.subviews objectAtIndex:0] removeFromSuperview];
[menu addSubview:searcher];
When I run this, it is as though the search bar is disabled. You cannot click on it or open up a keyboard. If I change the vertical position of the search bar from -216 to 0, I can click on it and bring up a keyboard, but I'm unable to type anything.
I'm a little confused about how I can implement this. Any ideas? I'm using Xcode 4.4 with ARC and storyboards.
That's how UIActionSheet
objects work. Do something else instead, like sliding up a UIView
.
From the Apple iOS Human Interface Guidelines:
Use an action sheet to:
Provide alternate ways a task can be completed. An action sheet allows you to provide a range of choices that make sense in the context of the current task, without giving these choices a permanent place in the user interface.
Get confirmation before completing a potentially dangerous task. An action sheet prompts users to think about the potentially dangerous effects of the step they’re about to take and gives them some alternatives. This type of communication is particularly important on iOS-based devices because sometimes users tap controls without meaning to.