Drag a push within the stance controller in addition to alter its championship to "Show AlertView".
We volition require to connect the push to the stance controller. Select the assistant editor in addition to opened upwards the ViewController.m file. Ctrl in addition to drag from the label to the cast department in addition to practise the next action.
Inside the ViewController.m, alter the line
@interface ViewController ()to
@interface ViewController () <UIAlertViewDelegate>
Inside the method of btn_showAlertView that nosotros accept created, insert this lines of code
UIAlertView * warning =[[UIAlertView alloc ] initWithTitle:@"OK Dialog" message:@"This is OK dialog" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles: nil]; [alert addButtonWithTitle:@"Cancel"]; [alert show];
To handgrip which push is clicked, insert this method
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex { if (buttonIndex == 0) { NSLog(@"You accept clicked Ok"); } else if(buttonIndex == 1) { NSLog(@"You accept clicked Cancel"); } }
Build in addition to Run the project, an warning stance should look when the "Show AlertView" push is clicked.
You tin download the beginning code of the SimpleAlertView at my repository on bitbucket.
0 komentar:
Please comment if there are any that need to be asked.