How to add a slide-up view with multiple buttons? Is there any ready-to-use component in Objective-c?
I want to add to my application a new view with buttons for sharing content or saving it to disk. I know how to do sharing itself (save, email), but I wonder if this layer should be created as frame or there is any ready-to-use class displaying modal ![alt text][1]layer for half screen?
I prefer to ask before doing it manually. I'm not sure if frame is only method of displaying this for half开发者_运维问答 screen size, or maybe I should display transparent layer and add only non-transparent rect with buttons for half screen?
I'm not able to add pictures yet, so I put example on my website: http://iphone.orpi.pl/?p=31
looking at the picture on your link, it's clear you're talking about an Action Sheet.
This is how you initialise & display one:
UIActionSheet *sheet = [[UIActionSheet alloc]initWithTitle:@"My Title"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:@"Go"
otherButtonTitles:@"Remind me Later",nil];
If you want to track clicks on the button, you must set the delegate (as above), and the delegate must conform to the UIActionSheetDelegate
protocol (set in the h file).
The event that you then override for handling the button taps is
- (void)actionSheet:(UIActionSheet *)actionSheet
clickedButtonAtIndex:(NSInteger)buttonIndex {
//code
}
I think, that one or two more lines may be helpful for other people to display sheet:
[sheet showInView:self.view];
[sheet release];
and one more hint to change astionsheet style
popupQuery.actionSheetStyle = UIActionSheetStyleBlackOpaque;
精彩评论