Modale Dialoge

Alerts

Beispiel Alerts

Beispiel Alerts

UIAlertView *alert = [[UIAlertView alloc] 
                      initWithTitle:@"Title" 
                      message:@"Message" 
                      delegate:nil 
                      cancelButtonTitle:@"Cancel" 
                      otherButtonTitles:@"Other", nil];
[alert show];
[alert release];

Action Sheets

Action Sheet

Beispiel Action Sheet

UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Title"
                delegate:self
                cancelButtonTitle:@"Cancel"
                destructiveButtonTitle:@"Destructive Button"
                otherButtonTitles:nil];

[actionSheet showInView:someView];
[actionSheet release];

Beispiel Action Sheet (UIActionSheetDelegate)

- (void) actionSheet: (UIActionSheet*) actionSheet
         clickedButtonAtIndex:(NSInteger) buttonIndex {

    if (buttonIndex == [actionSheet destructiveButtonIndex]) {
        // ...
    }

}

Modale View-Controller

Beispielcode: Modaler View-Controller mit Navigation-Bar

UIViewController* someViewController = [[SomeViewController alloc] init];
UINavigationController *modalNavController = [[UINavigationController alloc]
        initWithRootViewController:someViewController];

[self.navigationController presentModalViewController:modalNavController
            animated:YES];

[someViewController release];
[navController release];

Weitere Informationen

Ralf Ebert

Ralf Ebert is an independent software developer, technical writer and trainer. He makes apps for Mac OS X and iOS and builds software solutions for companies using Eclipse RCP and Ruby on Rails. He offers training courses for software developers and writes books and articles about software development.