ITeye博客

UIAlertView的基本操作

helmsman_xcode · 2011-08-15 17:59 · ios-综合基础文章 · 移动开发 · Markdown

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的值即可。

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。