UIActionSheet和UIAlertController

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];

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容