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

你可能感兴趣的:(UIActionSheet和UIAlertController)