Thank for the post, header file information was useful for me.
I was missing that.
Quote:
Originally Posted by Stitch
This is taken from the UICatalog sample code.
Insure your header file contains the following:
Code:
@interface YourViewController : UIViewController <UIAlertViewDelegate>
Then just add the following in the class you need the alert:
Code:
- (void)alertOKCancelAction {
// open a alert with an OK and cancel button
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"UIAlertView" message:@"<Alert message>" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
[alert show];
[alert release];
}
and
Code:
- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
// the user clicked one of the OK/Cancel buttons
if (buttonIndex == 0)
{
NSLog(@"ok");
}
else
{
NSLog(@"cancel");
}
}
|