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

原问题来自于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}}
}


 


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部