UIAlertView*alert = [[UIAlertView alloc]initWithTitle:@"提示"
message:@"请选择一个按钮:"
delegate:nil
cancelButtonTitle:@"取消"
otherButtonTitles:@"按钮一", @"按钮二", @"按钮三",nil];
[alert show];
[alert release];
3. 如何判断用户点击的按钮
UIAlertView有一个委托(代理)UIAlertViewDelegate ,继承该委托来实现点击事件
头文件:
复制代码@interface MyAlertViewViewController : UIViewController {
}
(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex;
-(IBAction) buttonPressed;
@end
源文件:










