Commit c49d55cf authored by Zhen Tan's avatar Zhen Tan Committed by GitHub

Merge pull request #164 from bringbird/master

消除因适配不同系统版本调用过期API的警告
parents 0ad0c02f 0de5bea9
...@@ -52,7 +52,10 @@ ...@@ -52,7 +52,10 @@
if (iOS9Later) { if (iOS9Later) {
barItem = [UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[TZImagePickerController class]]]; barItem = [UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[TZImagePickerController class]]];
} else { } else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
barItem = [UIBarButtonItem appearanceWhenContainedIn:[TZImagePickerController class], nil]; barItem = [UIBarButtonItem appearanceWhenContainedIn:[TZImagePickerController class], nil];
#pragma clang diagnostic pop
} }
NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary]; NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
textAttrs[NSForegroundColorAttributeName] = [UIColor whiteColor]; textAttrs[NSForegroundColorAttributeName] = [UIColor whiteColor];
...@@ -63,7 +66,10 @@ ...@@ -63,7 +66,10 @@
- (void)viewWillAppear:(BOOL)animated { - (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated]; [super viewWillAppear:animated];
_originStatusBarStyle = [UIApplication sharedApplication].statusBarStyle; _originStatusBarStyle = [UIApplication sharedApplication].statusBarStyle;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[UIApplication sharedApplication].statusBarStyle = iOS7Later ? UIStatusBarStyleLightContent : UIStatusBarStyleBlackOpaque; [UIApplication sharedApplication].statusBarStyle = iOS7Later ? UIStatusBarStyleLightContent : UIStatusBarStyleBlackOpaque;
#pragma clang diagnostic pop
} }
- (void)viewWillDisappear:(BOOL)animated { - (void)viewWillDisappear:(BOOL)animated {
...@@ -164,7 +170,10 @@ ...@@ -164,7 +170,10 @@
[alertController addAction:[UIAlertAction actionWithTitle:@"我知道了" style:UIAlertActionStyleDefault handler:nil]]; [alertController addAction:[UIAlertAction actionWithTitle:@"我知道了" style:UIAlertActionStyleDefault handler:nil]];
[self presentViewController:alertController animated:YES completion:nil]; [self presentViewController:alertController animated:YES completion:nil];
} else { } else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[[[UIAlertView alloc] initWithTitle:title message:nil delegate:nil cancelButtonTitle:@"我知道了" otherButtonTitles:nil, nil] show]; [[[UIAlertView alloc] initWithTitle:title message:nil delegate:nil cancelButtonTitle:@"我知道了" otherButtonTitles:nil, nil] show];
#pragma clang diagnostic pop
} }
} }
...@@ -270,7 +279,11 @@ ...@@ -270,7 +279,11 @@
backButton.titleLabel.font = [UIFont systemFontOfSize:15]; backButton.titleLabel.font = [UIFont systemFontOfSize:15];
[backButton addTarget:self action:@selector(popViewControllerAnimated:) forControlEvents:UIControlEventTouchUpInside]; [backButton addTarget:self action:@selector(popViewControllerAnimated:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem* backButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton]; UIBarButtonItem* backButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
backButtonItem.style = UIBarButtonItemStyleBordered; backButtonItem.style = UIBarButtonItemStyleBordered;
#pragma clang diagnostic pop
self.topViewController.navigationItem.backBarButtonItem = backButtonItem; self.topViewController.navigationItem.backBarButtonItem = backButtonItem;
/** /**
......
...@@ -50,8 +50,11 @@ static CGSize AssetGridThumbnailSize; ...@@ -50,8 +50,11 @@ static CGSize AssetGridThumbnailSize;
tzBarItem = [UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[TZImagePickerController class]]]; tzBarItem = [UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[TZImagePickerController class]]];
BarItem = [UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[UIImagePickerController class]]]; BarItem = [UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[UIImagePickerController class]]];
} else { } else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
tzBarItem = [UIBarButtonItem appearanceWhenContainedIn:[TZImagePickerController class], nil]; tzBarItem = [UIBarButtonItem appearanceWhenContainedIn:[TZImagePickerController class], nil];
BarItem = [UIBarButtonItem appearanceWhenContainedIn:[UIImagePickerController class], nil]; BarItem = [UIBarButtonItem appearanceWhenContainedIn:[UIImagePickerController class], nil];
#pragma clang diagnostic pop
} }
NSDictionary *titleTextAttributes = [tzBarItem titleTextAttributesForState:UIControlStateNormal]; NSDictionary *titleTextAttributes = [tzBarItem titleTextAttributesForState:UIControlStateNormal];
[BarItem setTitleTextAttributes:titleTextAttributes forState:UIControlStateNormal]; [BarItem setTitleTextAttributes:titleTextAttributes forState:UIControlStateNormal];
...@@ -399,9 +402,12 @@ static CGSize AssetGridThumbnailSize; ...@@ -399,9 +402,12 @@ static CGSize AssetGridThumbnailSize;
- (void)takePhoto { - (void)takePhoto {
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo]; AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
if ((authStatus == AVAuthorizationStatusRestricted || authStatus ==AVAuthorizationStatusDenied) && iOS8Later) { if ((authStatus == AVAuthorizationStatusRestricted || authStatus ==AVAuthorizationStatusDenied) && iOS8Later) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
// 无权限 做一个友好的提示 // 无权限 做一个友好的提示
UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"无法使用相机" message:@"请在iPhone的""设置-隐私-相机""中允许访问相机" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"设置", nil]; UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"无法使用相机" message:@"请在iPhone的""设置-隐私-相机""中允许访问相机" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"设置", nil];
[alert show]; [alert show];
#pragma clang diagnostic pop
} else { // 调用相机 } else { // 调用相机
UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera; UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera;
if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) { if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) {
...@@ -497,7 +503,10 @@ static CGSize AssetGridThumbnailSize; ...@@ -497,7 +503,10 @@ static CGSize AssetGridThumbnailSize;
#pragma mark - UIAlertViewDelegate #pragma mark - UIAlertViewDelegate
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
#pragma clang diagnostic pop
if (buttonIndex == 1) { // 去设置界面,开启相机访问权限 if (buttonIndex == 1) { // 去设置界面,开启相机访问权限
if (iOS8Later) { if (iOS8Later) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]]; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
......
...@@ -52,9 +52,12 @@ ...@@ -52,9 +52,12 @@
if ([asset isKindOfClass:[PHAsset class]]) { if ([asset isKindOfClass:[PHAsset class]]) {
PHAsset *phAsset = asset; PHAsset *phAsset = asset;
_videoImageView.hidden = phAsset.mediaType != PHAssetMediaTypeVideo; _videoImageView.hidden = phAsset.mediaType != PHAssetMediaTypeVideo;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
} else if ([asset isKindOfClass:[ALAsset class]]) { } else if ([asset isKindOfClass:[ALAsset class]]) {
ALAsset *alAsset = asset; ALAsset *alAsset = asset;
_videoImageView.hidden = ![[alAsset valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypeVideo]; _videoImageView.hidden = ![[alAsset valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypeVideo];
#pragma clang diagnostic pop
} }
} }
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
- (UIImagePickerController *)imagePickerVc { - (UIImagePickerController *)imagePickerVc {
if (_imagePickerVc == nil) { if (_imagePickerVc == nil) {
_imagePickerVc = [[UIImagePickerController alloc] init]; _imagePickerVc = [[UIImagePickerController alloc] init];
_imagePickerVc.delegate = self; _imagePickerVc.delegate = self; // *** 这句代码多余的????***
// set appearance / 改变相册选择页的导航栏外观 // set appearance / 改变相册选择页的导航栏外观
_imagePickerVc.navigationBar.barTintColor = self.navigationController.navigationBar.barTintColor; _imagePickerVc.navigationBar.barTintColor = self.navigationController.navigationBar.barTintColor;
_imagePickerVc.navigationBar.tintColor = self.navigationController.navigationBar.tintColor; _imagePickerVc.navigationBar.tintColor = self.navigationController.navigationBar.tintColor;
...@@ -50,8 +50,11 @@ ...@@ -50,8 +50,11 @@
tzBarItem = [UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[TZImagePickerController class]]]; tzBarItem = [UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[TZImagePickerController class]]];
BarItem = [UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[UIImagePickerController class]]]; BarItem = [UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[UIImagePickerController class]]];
} else { } else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
tzBarItem = [UIBarButtonItem appearanceWhenContainedIn:[TZImagePickerController class], nil]; tzBarItem = [UIBarButtonItem appearanceWhenContainedIn:[TZImagePickerController class], nil];
BarItem = [UIBarButtonItem appearanceWhenContainedIn:[UIImagePickerController class], nil]; BarItem = [UIBarButtonItem appearanceWhenContainedIn:[UIImagePickerController class], nil];
#pragma clang diagnostic pop
} }
NSDictionary *titleTextAttributes = [tzBarItem titleTextAttributesForState:UIControlStateNormal]; NSDictionary *titleTextAttributes = [tzBarItem titleTextAttributesForState:UIControlStateNormal];
[BarItem setTitleTextAttributes:titleTextAttributes forState:UIControlStateNormal]; [BarItem setTitleTextAttributes:titleTextAttributes forState:UIControlStateNormal];
...@@ -111,7 +114,10 @@ ...@@ -111,7 +114,10 @@
if (indexPath.row == _selectedPhotos.count) { if (indexPath.row == _selectedPhotos.count) {
BOOL showSheet = self.showSheetSwitch.isOn; BOOL showSheet = self.showSheetSwitch.isOn;
if (showSheet) { if (showSheet) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"拍照",@"去相册选择", nil]; UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"拍照",@"去相册选择", nil];
#pragma clang diagnostic pop
[sheet showInView:self.view]; [sheet showInView:self.view];
} else { } else {
[self pushImagePickerController]; [self pushImagePickerController];
...@@ -122,9 +128,12 @@ ...@@ -122,9 +128,12 @@
if ([asset isKindOfClass:[PHAsset class]]) { if ([asset isKindOfClass:[PHAsset class]]) {
PHAsset *phAsset = asset; PHAsset *phAsset = asset;
isVideo = phAsset.mediaType == PHAssetMediaTypeVideo; isVideo = phAsset.mediaType == PHAssetMediaTypeVideo;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
} else if ([asset isKindOfClass:[ALAsset class]]) { } else if ([asset isKindOfClass:[ALAsset class]]) {
ALAsset *alAsset = asset; ALAsset *alAsset = asset;
isVideo = [[alAsset valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypeVideo]; isVideo = [[alAsset valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypeVideo];
#pragma clang diagnostic pop
} }
if (isVideo) { // perview video / 预览视频 if (isVideo) { // perview video / 预览视频
TZVideoPlayerController *vc = [[TZVideoPlayerController alloc] init]; TZVideoPlayerController *vc = [[TZVideoPlayerController alloc] init];
...@@ -201,8 +210,11 @@ ...@@ -201,8 +210,11 @@
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo]; AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
if ((authStatus == AVAuthorizationStatusRestricted || authStatus == AVAuthorizationStatusDenied) && iOS8Later) { if ((authStatus == AVAuthorizationStatusRestricted || authStatus == AVAuthorizationStatusDenied) && iOS8Later) {
// 无权限 做一个友好的提示 // 无权限 做一个友好的提示
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"无法使用相机" message:@"请在iPhone的""设置-隐私-相机""中允许访问相机" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"设置", nil]; UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"无法使用相机" message:@"请在iPhone的""设置-隐私-相机""中允许访问相机" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"设置", nil];
[alert show]; [alert show];
#define push @#clang diagnostic pop
} else { // 调用相机 } else { // 调用相机
UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera; UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera;
if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) { if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) {
...@@ -249,7 +261,10 @@ ...@@ -249,7 +261,10 @@
#pragma mark - UIActionSheetDelegate #pragma mark - UIActionSheetDelegate
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
#pragma clang diagnostic pop
if (buttonIndex == 0) { // take photo / 去拍照 if (buttonIndex == 0) { // take photo / 去拍照
[self takePhoto]; [self takePhoto];
} else if (buttonIndex == 1) { } else if (buttonIndex == 1) {
...@@ -259,7 +274,10 @@ ...@@ -259,7 +274,10 @@
#pragma mark - UIAlertViewDelegate #pragma mark - UIAlertViewDelegate
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
#pragma clang diagnostic pop
if (buttonIndex == 1) { // 去设置界面,开启相机访问权限 if (buttonIndex == 1) { // 去设置界面,开启相机访问权限
if (iOS8Later) { if (iOS8Later) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]]; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
......
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