Multiple UIAlertView in Objective C - iOS,XCode
In iPhone mobile applications you can show alerts to users to give some message and so on.
Xcode provides a mechanism called UIAlertView for this. This article let you know how to pop up a UIAlertView and how to catch their button click events.
First I show you how to show a uialertview to user.
UIAlertView* dialog = [[UIAlertView alloc] initWithTitle:@"Hello"
UIAlertView* dialog2 = [[UIAlertView alloc] initWithTitle:@"Hello World"
Xcode provides a mechanism called UIAlertView for this. This article let you know how to pop up a UIAlertView and how to catch their button click events.
First I show you how to show a uialertview to user.
UIAlertView* dialog = [[UIAlertView alloc] initWithTitle:@"Hello"
                                                                      message:@""                                                                     delegate:self                                                            cancelButtonTitle:@"Cancel"
                                                            otherButtonTitles:@"OK", nil];
                     dialog.tag = 1;                     [dialog show];
UIAlertView* dialog2 = [[UIAlertView alloc] initWithTitle:@"Hello World"
                                                                      message:@""                                                                     delegate:self                                                            cancelButtonTitle:@"Cancel"
                                                            otherButtonTitles:@"OK", nil];
                     dialog2.tag = 2;                     [dialog2 show];
Above code snippets show you a pop up message says 'Hello'. And there are two buttons such 'cancel' & 'OK'. And below I shows how UIAlertView button click event catch and if multiple UIAlertViews are in the view controller class and how filter button click of which one.
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSIntege
    if (alertView.tag == 1) {
        // Hello UIAlertViewClick
    }
    else if (alertView.tag == 2) {
        // Hello World UiAlertViewClick
    }
}
Comments
Post a Comment