UIAlertView的基本操作
UIAlertView 提示框
定义并显示:
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"title" message:nil delegate:nil
cancelButtonTitle:@"button" otherButtonTitles: @"otherButton",nil];
[alert show];
[alert release];
多个按钮可对otherButtonTitles进行设置 例如:otherButtonTitles: @"otherButtonOne",@"otherButtonTwo",nil
当多个按钮是判断按下了哪个按钮,首先要遵守 UIAlertViewDelegate 协议
重写方法:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(buttonIndex == 0){
NSLog(@"The First Button Pressed");
}else if(buttonIndex == 1){
NSLog(@"The Second Button Pressed");
}else{
.....
}
判断buttonIndex的值即可。