I learned how to create a view controller and make the view slide in from bottom. But the one in iphone album looks different. It darkens the rest of the visible portion of the screen when the view slides in. How do I create a similar one? I want to add buttons like "save, cancel, email" etc into the sliding view.
This actually isn't a typical "sliding" (or modal) view, but a UIActionSheet. Basically, the idea is that you initialize the view (usually in your view controller) with
UIActionSheet *sheet =
[[[UIActionSheet alloc] initWithTitle:@"My sheet"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:@"Email", @"MMS", nil] autorelease];
Then present it using
[sheet showInView:[self view]];
Once it's onscreen, the delegate (self
, or your view controller, in this example) will receive the UIActionSheetDelegate message actionSheet:clickedButtonAtIndex:
(as well as some others; see the documentation for more), so you'll want to add <UIActionSheetDelegate>
to your interface declaration for the delegate and implement that method, like
- (void)actionSheet:(UIActionSheet *)actionSheet
clickedButtonAtIndex:(NSInteger)buttonIndex {
switch(buttonIndex) {
// Do things based on which button was pushed
}
}