Monday, January 11, 2010

AlertView

The creation and usage of Alert is very similar to Action Sheet.

Here, a AlertView will be shown if user click NO in the Action Sheet, to prompt user that the application is kept running.




- (void)actionSheet:(UIActionSheet *)actionSheet 
didDismissWithButtonIndex:(NSInteger)buttonIndex 
{ 
    if (buttonIndex == [actionSheet destructiveButtonIndex]) 
    { 
  exit(0);
    } 
 else
 {
  UIAlertView *alert =[[UIAlertView alloc]
        initWithTitle:@"No Exit"
        message:@"Application keep running"
        delegate:self
        cancelButtonTitle:@"OK"
        otherButtonTitles:nil];
  [alert show];
  [alert release];
 }
}