此範例為點擊按鈕,顯示UIAlertView,

透過buttonIndex可得知點擊了哪個按鈕

viewController.m

#import "ViewController.h"

@interface ViewController ()

- (IBAction)toShow:(id)sender;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)toShow:(id)sender {
    
    UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"alertView" message:@"plz choice" delegate:self cancelButtonTitle:@"cancle:" otherButtonTitles:@"save",@"load", nil];
    [alertView show];
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    
    NSLog(@"%ld",(long)buttonIndex);
}

@end

 

arrow
arrow
    文章標籤
    UIAlertView
    全站熱搜

    Will 發表在 痞客邦 留言(0) 人氣()