UIAlertView笔记

 

头文件: 

@interface MyAlertViewViewController : UIViewController<UIAlertViewDelegate> { 

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex; 

-(IBAction) buttonPressed; 

@end


源文件: 

-(IBAction) buttonPressed 

UIAlertView*alert = [[UIAlertView alloc]initWithTitle:@"提示" 

message:@"请选择一个按钮:" 

delegate:self 

cancelButtonTitle:@"取消" 

otherButtonTitles:@"按钮一", @"按钮二", @"按钮三",nil]; 

[alert show];

}  

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 

{

NSString* msg = [[NSString alloc] initWithFormat:@"您按下的第%d个按钮!",buttonIndex]; 

UIAlertView* alert = [[UIAlertView alloc]initWithTitle:@"提示" 

message:msg 

delegate:nil 

cancelButtonTitle:@"确定" 

otherButtonTitles:nil];  

[alert show]; 

}

posted @ 2014-12-22 11:17  我去ios  阅读(117)  评论(0编辑  收藏  举报