iOS中如何用UIAlertView来确认提交动作?

问答小助手 2013-02-28 11:24:20
加精
原问题来自于CSDN问答频道,更多解决方案见:http://ask.csdn.net/questions/1519

原问题描述:
大家好,请教一个关于UIGestureRecognizer的问题。
比如我需要在用户在操作之后,用UIAlertView来确认提交动作,我试过一些方法都没成功。

解决方案:
这样:
UISwipeGestureRecognizer *gesture1 = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(didSwipeRight:)];
gesture1.direction = UISwipeGestureRecognizerDirectionRight;
[yourView addGestureRecognizer:gesture1];

在Action方法中:
-(void)didSwipeLeft:(UIGestureRecognizer *)gestureRecognizer {
UIAlertView *Alert = [[UIAlertView alloc] initWithTitle:@"" message:@"Are you sure to commit with its action" delegate:self cancelButtonTitle:CKString(@"NO") otherButtonTitles:CKString(@"YES"),nil];
[Alert show];
Alert.tag=222;
Alert.delegate=self;
[Alert release];
}

在AlertView Delegate
-(void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {

if(alertView.tag==222) {
if(buttonIndex==1)
{
//// Yes condition
} else {
///// No condition
}
}
}
...全文
2682 36 打赏 收藏 转发到动态 举报
写回复
用AI写文章
36 条回复
切换为时间正序
请发表友善的回复…
发表回复
newbairdofios 2015-09-24
  • 打赏
  • 举报
回复
很不错 已学习
wallier 2013-03-12
  • 打赏
  • 举报
回复
没领悟,什么代理啊。
wallier 2013-03-11
  • 打赏
  • 举报
回复
sky123468 2013-03-11
  • 打赏
  • 举报
回复
好吧,跪了学习
hillsjiantone 2013-03-09
  • 打赏
  • 举报
回复
不错,好帖子!
MZ_Best 2013-03-09
  • 打赏
  • 举报
回复
努力学习中。。。
胡_码农 2013-03-07
  • 打赏
  • 举报
回复
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"转账确认" message:info delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil]; alertView.tag = 1001; [alertView show]; [alertView release]; 弹出框应该这样写,必须先设置它的tag再show出来,才管用弹出框的委托方法
wang19930222 2013-03-06
  • 打赏
  • 举报
回复
scripts/csdn/Plugin/001/face/79.gif][/img]
tomxi_kinghan 2013-03-06
  • 打赏
  • 举报
回复
学习!!!努力学习中!!!!!!!!
leiuoo 2013-03-05
  • 打赏
  • 举报
回复
用UIAlertView来确认提交动作
xiaoyaokk 2013-03-05
  • 打赏
  • 举报
回复
AlertView的代理方法
爱学习的panda 2013-03-05
  • 打赏
  • 举报
回复
不错的帖子,学习了~~~
luolongjie111 2013-03-03
  • 打赏
  • 举报
回复
这个有点深奥 我是小白
lhw7791086 2013-03-03
  • 打赏
  • 举报
回复
historyarea 2013-03-03
  • 打赏
  • 举报
回复
好!!!
lhw7791086 2013-03-02
  • 打赏
  • 举报
回复
zengyang1111 2013-03-02
  • 打赏
  • 举报
回复
lsq47849659 2013-03-02
  • 打赏
  • 举报
回复
wolf007hero 2013-03-01
  • 打赏
  • 举报
回复
我哈哈。。。。。
qi_ruihua 2013-02-28
  • 打赏
  • 举报
回复
关键是代理方法嘛
加载更多回复(4)

29,027

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧