六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 183|回复: 0

iphone 确认框与提示框

[复制链接]

升级  84%

10

主题

10

主题

10

主题

童生

Rank: 1

积分
42
 楼主| 发表于 2013-1-14 21:19:44 | 显示全部楼层 |阅读模式
   首先Controller需要遵守UIActionSheetDelegate协议,如:
 
@interface SampleController : UIViewController<UIActionSheetDelegate>    Controller实现中可以这样触发确认框:
 
   UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Are you sure?"        delegate:selfcancelButtonTitle:@"No way!"destructiveButtonTitle:@"Yes,I'm Sure!"otherButtonTitles:nil        ];   [actionSheet showInView:self.view];   [actionSheet release];    Controller确认框事件:
 
-(void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex{if(buttonIndex !=[actionSheet cancelButtonIndex]){NSString *msg = nil;if(nameField.text.length>0){msg = [[NSString alloc] initWithFormat:@"You can breathe easy ,%@,everything went OK>",nameField.text];}else{msg = @"You can breathe easy,everything went OK.";}UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"something was" message:msg delegate:self cancelButtonTitle:@"phew!" otherButtonTitles:nil];[alert show];[alert release];[msg release];}}  
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表