Wednesday, May 29, 2013

UIActionSheet showInView example in Objective C (iOS).

UIActionSheet showInView

Displays an action sheet that originates from the specified view.

- (void)showInView:(UIView *)view

Parameters of [UIActionSheet showInView]
view
The view from which the action sheet originates.

Discussion of [UIActionSheet showInView]
The appearance of the action sheet is animated.

On iPad, this method centers the action sheet in the middle of the screen. Generally, if you want to present an action sheet in an iPad application, you should use the showFromRect:inView:animated: method to display the action sheet instead.

UIActionSheet showInView example.
- (void)showOpenOptions
{
UIActionSheet *sheet = [[UIActionSheet alloc]
initWithTitle:NSLocalizedString(@"Open link in external application?", @"Open in external application")
delegate:self
cancelButtonTitle:NSLocalizedString(@"Cancel", @"Cancel")
destructiveButtonTitle:NSLocalizedString(@"Open Link", @"Open Link")
otherButtonTitles:nil];

[sheet showInView:self.parentViewController.tabBarController.view];
[sheet release];
}

Example of [UIActionSheet showInView].
UIActionsheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Alarm"
                                    delegate:self
                           cancelButtonTitle:nil
                      destructiveButtonTitle:@"Dismiss"
                               otherButtonTitles:nil];

[actionSheet showInView:[self view]];

UIActionSheet showInView example.
[actionSheet showInView:self.viewController.view]

End of UIActionSheet showInView example article.