首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >确认UIGestureRecognizer?

确认UIGestureRecognizer?
EN

Stack Overflow用户
提问于 2013-02-27 12:08:39
回答 2查看 109关注 0票数 1

例如,当我使用UIGestureRecognizer时,当用户向右滑动时,我希望有一个UIAlertView询问他是否真的想要提交向右滑动的操作。

我试过这样做,但没有成功。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-02-27 12:16:07

像这样做,

代码语言:javascript
复制
UISwipeGestureRecognizer *gesture1 = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(didSwipeRight:)];
gesture1.direction = UISwipeGestureRecognizerDirectionRight;
[yourView addGestureRecognizer:gesture1];

在Action方法中,

代码语言:javascript
复制
-(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委托中

代码语言:javascript
复制
-(void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {

    if(alertView.tag==222) {
        if(buttonIndex==1)
        {
            //// Yes condition
        } else {
           ///// No condition
        }
    }
}
票数 1
EN

Stack Overflow用户

发布于 2013-02-27 12:12:14

UIGestureRecogniser事件方法中,使用适当的标题/消息创建一个UIAlertView

UIAlertView的委托设置为self,在alertView:didDismissWithButtonIndex:中,您可以根据用户点击的内容执行操作,也可以不执行操作。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15104042

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档