美文网首页
UIActionSheet和UIAlertController

UIActionSheet和UIAlertController

作者: 水灵芳蕥 | 来源:发表于2021-09-26 11:38 被阅读0次

    1、底部:UIActionSheet

    https://blog.csdn.net/potato512/article/details/51534645

    长按:

    UILongPressGestureRecognizer *longPressGesture = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(longPressImage:)];

            [selfaddGestureRecognizer:longPressGesture];

    - (void)longPressImage:(UITapGestureRecognizer*)tap

    {

        UIActionSheet *actionsheet = [[UIActionSheet alloc] initWithTitle:nil delegate:_photo.imgVc cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"保存到本地", nil];

        [actionsheetshowInView:self];

    }

    代理:

    - (void)actionSheet:(UIActionSheet*)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex

    {

        NSString*title = [actionSheetbuttonTitleAtIndex:buttonIndex];

        if([titleisEqualToString:@"保存到本地"])

        {

            //点确定

        }

        if(buttonIndex ==0)

        {

            //点确定

        }

    }

    2、中间

    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"保存到本地" message:nil preferredStyle: UIAlertControllerStyleAlert];

       [alertaddAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

           [_photo.imgVc dismissViewControllerAnimated:YES completion:nil];

        }]];

        [_photo.imgVc presentViewController:alert animated:true completion:nil];

    相关文章

      网友评论

          本文标题:UIActionSheet和UIAlertController

          本文链接:https://www.haomeiwen.com/subject/pvfkjftx.html