目的:點選按鈕出現訊息視窗step2. ViewController.h
@interface ViewController : UIViewController
{
IBOutlet id mylab;
}
-(IBAction)onClick:(id)sender;
@end
step3. ViewController.m
@implementation ViewController
-(IBAction)onClick:(id)sender {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"訊息標題" message:@"請選擇" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"儲存", @"產生", nil];
[alert show];
}
-(void)alertView:(UIAlertView *)sender clickedButtonAtIndex:(NSInteger)buttonIndex {
switch (buttonIndex) {
case 0:
[mylab setText:@"cancel"];
break;
case 1:
[mylab setText:@"save"];
break;
case 2:
[mylab setText:@"load"];
break;
default:
break;
}
}