Commit f6ff3f35 authored by yuzheng.tz's avatar yuzheng.tz

demo页弃用UIActionSheet,升级为UIAlertController

parent 0e3bc8ef
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#import "TZAssetCell.h" #import "TZAssetCell.h"
#import <MobileCoreServices/MobileCoreServices.h> #import <MobileCoreServices/MobileCoreServices.h>
@interface ViewController ()<TZImagePickerControllerDelegate,UICollectionViewDataSource,UICollectionViewDelegate,UIActionSheetDelegate,UIImagePickerControllerDelegate,UIAlertViewDelegate,UINavigationControllerDelegate> { @interface ViewController ()<TZImagePickerControllerDelegate,UICollectionViewDataSource,UICollectionViewDelegate,UIImagePickerControllerDelegate,UIAlertViewDelegate,UINavigationControllerDelegate> {
NSMutableArray *_selectedPhotos; NSMutableArray *_selectedPhotos;
NSMutableArray *_selectedAssets; NSMutableArray *_selectedAssets;
BOOL _isSelectOriginalPhoto; BOOL _isSelectOriginalPhoto;
...@@ -170,8 +170,25 @@ ...@@ -170,8 +170,25 @@
} else if (self.showTakeVideoBtnSwitch.isOn) { } else if (self.showTakeVideoBtnSwitch.isOn) {
takePhotoTitle = @"拍摄"; takePhotoTitle = @"拍摄";
} }
UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:takePhotoTitle,@"去相册选择", nil]; UIAlertController *alertVc = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
[sheet showInView:self.view]; UIAlertAction *takePhotoAction = [UIAlertAction actionWithTitle:takePhotoTitle style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[self takePhoto];
}];
[alertVc addAction:takePhotoAction];
UIAlertAction *imagePickerAction = [UIAlertAction actionWithTitle:@"去相册选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[self pushTZImagePickerController];
}];
[alertVc addAction:imagePickerAction];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
[alertVc addAction:cancelAction];
UIPopoverPresentationController *popover = alertVc.popoverPresentationController;
UICollectionViewCell *cell = [collectionView cellForItemAtIndexPath:indexPath];
if (popover) {
popover.sourceView = cell;
popover.sourceRect = cell.bounds;
popover.permittedArrowDirections = UIPopoverArrowDirectionAny;
}
[self presentViewController:alertVc animated:YES completion:nil];
} else { } else {
[self pushTZImagePickerController]; [self pushTZImagePickerController];
} }
...@@ -523,16 +540,6 @@ ...@@ -523,16 +540,6 @@
} }
} }
#pragma mark - UIActionSheetDelegate
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0) { // take photo / 去拍照
[self takePhoto];
} else if (buttonIndex == 1) {
[self pushTZImagePickerController];
}
}
#pragma mark - UIAlertViewDelegate #pragma mark - UIAlertViewDelegate
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment