iOS中用户在操作后如何用UIAlertView来确认提交

iOS 码拜 9年前 (2015-09-29) 893次浏览
问题描述:

请教一个关于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
        }
    }
}
iOS中用户在操作后如何用UIAlertView来确认提交
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@”转账确认”

                                                        message:info

                                                       delegate:self

                                                    cancelButtonTitle:@”取消”

                                                    otherButtonTitles:@”确定”, nil];

    alertView.tag = 1001;

    [alertView show];

    [alertView release];

弹出框应该这样写,必须先设置它的tag再show出来,才管用弹出框的委托方法


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明iOS中用户在操作后如何用UIAlertView来确认提交
喜欢 (0)
[1034331897@qq.com]
分享 (0)