Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
dz_TZImagePickerController
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
shuijing
dz_TZImagePickerController
Commits
c278047c
Commit
c278047c
authored
Aug 12, 2016
by
bringbird
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
消除因适配不同系统版本调用过期API的警告
parent
0ad0c02f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
110 additions
and
2 deletions
+110
-2
TZImagePickerController/TZImagePickerController/TZImageManager.m
...PickerController/TZImagePickerController/TZImageManager.m
+79
-1
TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m
...troller/TZImagePickerController/TZPhotoPickerController.m
+9
-0
TZImagePickerController/TZTestCell.m
TZImagePickerController/TZTestCell.m
+3
-0
TZImagePickerController/ViewController.m
TZImagePickerController/ViewController.m
+19
-1
No files found.
TZImagePickerController/TZImagePickerController/TZImageManager.m
View file @
c278047c
...
...
@@ -12,7 +12,10 @@
#import "TZImagePickerController.h"
@interface
TZImageManager
()
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
@property
(
nonatomic
,
strong
)
ALAssetsLibrary
*
assetLibrary
;
#pragma clang diagnostic pop
@end
@implementation
TZImageManager
...
...
@@ -42,8 +45,11 @@ static CGFloat TZScreenScale;
return
manager
;
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
-
(
ALAssetsLibrary
*
)
assetLibrary
{
if
(
_assetLibrary
==
nil
)
_assetLibrary
=
[[
ALAssetsLibrary
alloc
]
init
];
#pragma clang diagnostic pop
return
_assetLibrary
;
}
...
...
@@ -52,7 +58,10 @@ static CGFloat TZScreenScale;
if
(
iOS8Later
)
{
if
([
PHPhotoLibrary
authorizationStatus
]
==
PHAuthorizationStatusAuthorized
)
return
YES
;
}
else
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
if
([
ALAssetsLibrary
authorizationStatus
]
==
ALAuthorizationStatusAuthorized
)
return
YES
;
#pragma clang diagnostic pop
}
return
NO
;
}
...
...
@@ -80,9 +89,13 @@ static CGFloat TZScreenScale;
}
}
}
else
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[
self
.
assetLibrary
enumerateGroupsWithTypes
:
ALAssetsGroupAll
usingBlock
:
^
(
ALAssetsGroup
*
group
,
BOOL
*
stop
)
{
if
([
group
numberOfAssets
]
<
1
)
return
;
NSString
*
name
=
[
group
valueForProperty
:
ALAssetsGroupPropertyName
];
#pragma clang diagnostic pop
if
([
name
isEqualToString
:
@"Camera Roll"
]
||
[
name
isEqualToString
:
@"相机胶卷"
]
||
[
name
isEqualToString
:
@"所有照片"
]
||
[
name
isEqualToString
:
@"All Photos"
])
{
model
=
[
self
modelWithResult
:
group
name
:
name
];
if
(
completion
)
completion
(
model
);
...
...
@@ -136,12 +149,18 @@ static CGFloat TZScreenScale;
}
if
(
completion
&&
albumArr
.
count
>
0
)
completion
(
albumArr
);
}
else
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[
self
.
assetLibrary
enumerateGroupsWithTypes
:
ALAssetsGroupAll
usingBlock
:
^
(
ALAssetsGroup
*
group
,
BOOL
*
stop
)
{
#pragma clang diagnostic pop
if
(
group
==
nil
)
{
if
(
completion
&&
albumArr
.
count
>
0
)
completion
(
albumArr
);
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
if
([
group
numberOfAssets
]
<
1
)
return
;
NSString
*
name
=
[
group
valueForProperty
:
ALAssetsGroupPropertyName
];
#pragma clang diagnostic pop
if
([
name
isEqualToString
:
@"Camera Roll"
]
||
[
name
isEqualToString
:
@"相机胶卷"
]
||
[
name
isEqualToString
:
@"所有照片"
]
||
[
name
isEqualToString
:
@"All Photos"
])
{
[
albumArr
insertObject
:[
self
modelWithResult
:
group
name
:
name
]
atIndex
:
0
];
}
else
if
([
name
isEqualToString
:
@"My Photo Stream"
]
||
[
name
isEqualToString
:
@"我的照片流"
])
{
...
...
@@ -182,6 +201,8 @@ static CGFloat TZScreenScale;
[
photoArr
addObject
:[
TZAssetModel
modelWithAsset
:
asset
type
:
type
timeLength
:
timeLength
]];
}];
if
(
completion
)
completion
(
photoArr
);
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
}
else
if
([
result
isKindOfClass
:[
ALAssetsGroup
class
]])
{
ALAssetsGroup
*
group
=
(
ALAssetsGroup
*
)
result
;
if
(
allowPickingImage
&&
allowPickingVideo
)
{
...
...
@@ -192,6 +213,7 @@ static CGFloat TZScreenScale;
[
group
setAssetsFilter
:[
ALAssetsFilter
allPhotos
]];
}
ALAssetsGroupEnumerationResultsBlock
resultBlock
=
^
(
ALAsset
*
result
,
NSUInteger
index
,
BOOL
*
stop
)
{
#pragma clang diagnostic pop
if
(
result
==
nil
)
{
if
(
completion
)
completion
(
photoArr
);
}
...
...
@@ -201,9 +223,12 @@ static CGFloat TZScreenScale;
return
;
}
/// Allow picking video
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
if
([[
result
valueForProperty
:
ALAssetPropertyType
]
isEqualToString
:
ALAssetTypeVideo
])
{
type
=
TZAssetModelMediaTypeVideo
;
NSTimeInterval
duration
=
[[
result
valueForProperty
:
ALAssetPropertyDuration
]
integerValue
];
#pragma clang diagnostic pop
NSString
*
timeLength
=
[
NSString
stringWithFormat
:
@"%0.0f"
,
duration
];
timeLength
=
[
self
getNewTimeFromDurationSecond
:
timeLength
.
integerValue
];
[
photoArr
addObject
:[
TZAssetModel
modelWithAsset
:
result
type
:
type
timeLength
:
timeLength
]];
...
...
@@ -211,12 +236,18 @@ static CGFloat TZScreenScale;
[
photoArr
addObject
:[
TZAssetModel
modelWithAsset
:
result
type
:
type
]];
}
};
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
if
(
self
.
sortAscendingByModificationDate
)
{
[
group
enumerateAssetsUsingBlock
:
^
(
ALAsset
*
result
,
NSUInteger
index
,
BOOL
*
stop
)
{
if
(
resultBlock
)
{
resultBlock
(
result
,
index
,
stop
);
}
#pragma clang diagnostic pop
}];
}
else
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[
group
enumerateAssetsWithOptions
:
NSEnumerationReverse
usingBlock
:
^
(
ALAsset
*
result
,
NSUInteger
index
,
BOOL
*
stop
)
{
#pragma clang diagnostic pop
if
(
resultBlock
)
{
resultBlock
(
result
,
index
,
stop
);
}
}];
}
...
...
@@ -249,6 +280,8 @@ static CGFloat TZScreenScale;
timeLength
=
[
self
getNewTimeFromDurationSecond
:
timeLength
.
integerValue
];
TZAssetModel
*
model
=
[
TZAssetModel
modelWithAsset
:
asset
type
:
type
timeLength
:
timeLength
];
if
(
completion
)
completion
(
model
);
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
}
else
if
([
result
isKindOfClass
:[
ALAssetsGroup
class
]])
{
ALAssetsGroup
*
group
=
(
ALAssetsGroup
*
)
result
;
if
(
allowPickingImage
&&
allowPickingVideo
)
{
...
...
@@ -258,10 +291,14 @@ static CGFloat TZScreenScale;
}
else
if
(
allowPickingImage
)
{
[
group
setAssetsFilter
:[
ALAssetsFilter
allPhotos
]];
}
#pragma clang diagnostic pop
NSIndexSet
*
indexSet
=
[
NSIndexSet
indexSetWithIndex
:
index
];
@try
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[
group
enumerateAssetsAtIndexes
:
indexSet
options
:
NSEnumerationConcurrent
usingBlock
:^
(
ALAsset
*
result
,
NSUInteger
index
,
BOOL
*
stop
)
{
#pragma clang diagnostic pop
if
(
!
result
)
return
;
...
...
@@ -273,9 +310,12 @@ static CGFloat TZScreenScale;
return
;
}
/// Allow picking video
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
if
([[
result
valueForProperty
:
ALAssetPropertyType
]
isEqualToString
:
ALAssetTypeVideo
])
{
type
=
TZAssetModelMediaTypeVideo
;
NSTimeInterval
duration
=
[[
result
valueForProperty
:
ALAssetPropertyDuration
]
integerValue
];
#pragma clang diagnostic pop
NSString
*
timeLength
=
[
NSString
stringWithFormat
:
@"%0.0f"
,
duration
];
timeLength
=
[
self
getNewTimeFromDurationSecond
:
timeLength
.
integerValue
];
model
=
[
TZAssetModel
modelWithAsset
:
result
type
:
type
timeLength
:
timeLength
];
...
...
@@ -325,9 +365,12 @@ static CGFloat TZScreenScale;
if
(
completion
)
completion
(
bytes
);
}
}];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
}
else
if
([
model
.
asset
isKindOfClass
:[
ALAsset
class
]])
{
ALAssetRepresentation
*
representation
=
[
model
.
asset
defaultRepresentation
];
if
(
model
.
type
!=
TZAssetModelMediaTypeVideo
)
dataLength
+=
(
NSInteger
)
representation
.
size
;
#pragma clang diagnostic pop
if
(
i
>=
photos
.
count
-
1
)
{
NSString
*
bytes
=
[
self
getBytesFromDataLength
:
dataLength
];
if
(
completion
)
completion
(
bytes
);
...
...
@@ -397,18 +440,24 @@ static CGFloat TZScreenScale;
}
}];
return
imageRequestID
;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
}
else
if
([
asset
isKindOfClass
:[
ALAsset
class
]])
{
ALAsset
*
alAsset
=
(
ALAsset
*
)
asset
;
dispatch_async
(
dispatch_get_global_queue
(
0
,
0
),
^
{
CGImageRef
thumbnailImageRef
=
alAsset
.
thumbnail
;
UIImage
*
thumbnailImage
=
[
UIImage
imageWithCGImage
:
thumbnailImageRef
scale
:
2
.
0
orientation
:
UIImageOrientationUp
];
#pragma clang diagnostic pop
dispatch_async
(
dispatch_get_main_queue
(),
^
{
if
(
completion
)
completion
(
thumbnailImage
,
nil
,
YES
);
if
(
photoWidth
==
TZScreenWidth
||
photoWidth
==
_photoPreviewMaxWidth
)
{
dispatch_async
(
dispatch_get_global_queue
(
0
,
0
),
^
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
ALAssetRepresentation
*
assetRep
=
[
alAsset
defaultRepresentation
];
CGImageRef
fullScrennImageRef
=
[
assetRep
fullScreenImage
];
#pragma clang diagnostic pop
UIImage
*
fullScrennImage
=
[
UIImage
imageWithCGImage
:
fullScrennImageRef
scale
:
2
.
0
orientation
:
UIImageOrientationUp
];
dispatch_async
(
dispatch_get_main_queue
(),
^
{
...
...
@@ -433,8 +482,11 @@ static CGFloat TZScreenScale;
if
(
completion
)
completion
(
photo
);
}];
}
else
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
ALAssetsGroup
*
group
=
model
.
result
;
UIImage
*
postImage
=
[
UIImage
imageWithCGImage
:
group
.
posterImage
];
#pragma clang diagnostic pop
if
(
completion
)
completion
(
postImage
);
}
}
...
...
@@ -451,12 +503,18 @@ static CGFloat TZScreenScale;
if
(
completion
)
completion
(
result
,
info
);
}
}];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
}
else
if
([
asset
isKindOfClass
:[
ALAsset
class
]])
{
ALAsset
*
alAsset
=
(
ALAsset
*
)
asset
;
ALAssetRepresentation
*
assetRep
=
[
alAsset
defaultRepresentation
];
#pragma clang diagnostic pop
dispatch_async
(
dispatch_get_global_queue
(
0
,
0
),
^
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
CGImageRef
originalImageRef
=
[
assetRep
fullResolutionImage
];
#pragma clang diagnostic pop
UIImage
*
originalImage
=
[
UIImage
imageWithCGImage
:
originalImageRef
scale
:
1
.
0
orientation
:
UIImageOrientationUp
];
dispatch_async
(
dispatch_get_main_queue
(),
^
{
...
...
@@ -485,7 +543,10 @@ static CGFloat TZScreenScale;
});
}];
}
else
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[
self
.
assetLibrary
writeImageToSavedPhotosAlbum
:
image
.
CGImage
orientation
:[
self
orientationFromImage
:
image
]
completionBlock
:^
(
NSURL
*
assetURL
,
NSError
*
error
)
{
#pragma clang diagnostic pop
if
(
error
)
{
NSLog
(
@"保存图片失败:%@"
,
error
.
localizedDescription
);
}
else
{
...
...
@@ -505,11 +566,14 @@ static CGFloat TZScreenScale;
[[
PHImageManager
defaultManager
]
requestPlayerItemForVideo
:
asset
options
:
nil
resultHandler
:^
(
AVPlayerItem
*
_Nullable
playerItem
,
NSDictionary
*
_Nullable
info
)
{
if
(
completion
)
completion
(
playerItem
,
info
);
}];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
}
else
if
([
asset
isKindOfClass
:[
ALAsset
class
]])
{
ALAsset
*
alAsset
=
(
ALAsset
*
)
asset
;
ALAssetRepresentation
*
defaultRepresentation
=
[
alAsset
defaultRepresentation
];
NSString
*
uti
=
[
defaultRepresentation
UTI
];
NSURL
*
videoURL
=
[[
asset
valueForProperty
:
ALAssetPropertyURLs
]
valueForKey
:
uti
];
#pragma clang diagnostic pop
AVPlayerItem
*
playerItem
=
[[
AVPlayerItem
alloc
]
initWithURL
:
videoURL
];
if
(
completion
&&
playerItem
)
completion
(
playerItem
,
nil
);
}
...
...
@@ -530,8 +594,11 @@ static CGFloat TZScreenScale;
// NSLog(@"AVAsset URL: %@",myAsset.URL);
[
self
startExportVideoWithVideoAsset
:
videoAsset
completion
:
completion
];
}];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
}
else
if
([
asset
isKindOfClass
:[
ALAsset
class
]])
{
NSURL
*
videoURL
=
[
asset
valueForProperty
:
ALAssetPropertyAssetURL
];
// ALAssetPropertyURLs
#pragma clang diagnostic pop
AVURLAsset
*
videoAsset
=
[[
AVURLAsset
alloc
]
initWithURL
:
videoURL
options
:
nil
];
[
self
startExportVideoWithVideoAsset
:
videoAsset
completion
:
completion
];
}
...
...
@@ -602,10 +669,13 @@ static CGFloat TZScreenScale;
return
[
assets
containsObject
:
asset
];
}
else
{
NSMutableArray
*
selectedAssetUrls
=
[
NSMutableArray
array
];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
for
(
ALAsset
*
asset_item
in
assets
)
{
[
selectedAssetUrls
addObject
:[
asset_item
valueForProperty
:
ALAssetPropertyURLs
]];
}
return
[
selectedAssetUrls
containsObject
:[
asset
valueForProperty
:
ALAssetPropertyURLs
]];
#pragma clang diagnostic pop
}
}
...
...
@@ -614,8 +684,11 @@ static CGFloat TZScreenScale;
PHAsset
*
phAsset
=
(
PHAsset
*
)
asset
;
return
phAsset
.
localIdentifier
;
}
else
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
ALAsset
*
alAsset
=
(
ALAsset
*
)
asset
;
NSURL
*
assetUrl
=
[
alAsset
valueForProperty
:
ALAssetPropertyAssetURL
];
#pragma clang diagnostic pop
return
assetUrl
.
absoluteString
;
}
}
...
...
@@ -629,9 +702,12 @@ static CGFloat TZScreenScale;
if
([
result
isKindOfClass
:[
PHFetchResult
class
]])
{
PHFetchResult
*
fetchResult
=
(
PHFetchResult
*
)
result
;
model
.
count
=
fetchResult
.
count
;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
}
else
if
([
result
isKindOfClass
:[
ALAssetsGroup
class
]])
{
ALAssetsGroup
*
group
=
(
ALAssetsGroup
*
)
result
;
model
.
count
=
[
group
numberOfAssets
];
#pragma clang diagnostic pop
}
return
model
;
}
...
...
@@ -665,8 +741,10 @@ static CGFloat TZScreenScale;
return
image
;
}
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
-
(
ALAssetOrientation
)
orientationFromImage
:(
UIImage
*
)
image
{
#pragma clang diagnostic pop
NSInteger
orientation
=
image
.
imageOrientation
;
return
orientation
;
}
...
...
TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m
View file @
c278047c
...
...
@@ -50,8 +50,11 @@ static CGSize AssetGridThumbnailSize;
tzBarItem
=
[
UIBarButtonItem
appearanceWhenContainedInInstancesOfClasses
:@[[
TZImagePickerController
class
]]];
BarItem
=
[
UIBarButtonItem
appearanceWhenContainedInInstancesOfClasses
:@[[
UIImagePickerController
class
]]];
}
else
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
tzBarItem
=
[
UIBarButtonItem
appearanceWhenContainedIn
:[
TZImagePickerController
class
],
nil
];
BarItem
=
[
UIBarButtonItem
appearanceWhenContainedIn
:[
UIImagePickerController
class
],
nil
];
#pragma clang diagnostic pop
}
NSDictionary
*
titleTextAttributes
=
[
tzBarItem
titleTextAttributesForState
:
UIControlStateNormal
];
[
BarItem
setTitleTextAttributes
:
titleTextAttributes
forState
:
UIControlStateNormal
];
...
...
@@ -399,9 +402,12 @@ static CGSize AssetGridThumbnailSize;
-
(
void
)
takePhoto
{
AVAuthorizationStatus
authStatus
=
[
AVCaptureDevice
authorizationStatusForMediaType
:
AVMediaTypeVideo
];
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
];
[
alert
show
];
#pragma clang diagnostic pop
}
else
{
// 调用相机
UIImagePickerControllerSourceType
sourceType
=
UIImagePickerControllerSourceTypeCamera
;
if
([
UIImagePickerController
isSourceTypeAvailable
:
UIImagePickerControllerSourceTypeCamera
])
{
...
...
@@ -497,7 +503,10 @@ static CGSize AssetGridThumbnailSize;
#pragma mark - UIAlertViewDelegate
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
-
(
void
)
alertView
:(
UIAlertView
*
)
alertView
clickedButtonAtIndex
:(
NSInteger
)
buttonIndex
{
#pragma clang diagnostic pop
if
(
buttonIndex
==
1
)
{
// 去设置界面,开启相机访问权限
if
(
iOS8Later
)
{
[[
UIApplication
sharedApplication
]
openURL
:[
NSURL
URLWithString
:
UIApplicationOpenSettingsURLString
]];
...
...
TZImagePickerController/TZTestCell.m
View file @
c278047c
...
...
@@ -52,9 +52,12 @@
if
([
asset
isKindOfClass
:[
PHAsset
class
]])
{
PHAsset
*
phAsset
=
asset
;
_videoImageView
.
hidden
=
phAsset
.
mediaType
!=
PHAssetMediaTypeVideo
;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
}
else
if
([
asset
isKindOfClass
:[
ALAsset
class
]])
{
ALAsset
*
alAsset
=
asset
;
_videoImageView
.
hidden
=
!
[[
alAsset
valueForProperty
:
ALAssetPropertyType
]
isEqualToString
:
ALAssetTypeVideo
];
#pragma clang diagnostic pop
}
}
...
...
TZImagePickerController/ViewController.m
View file @
c278047c
...
...
@@ -41,7 +41,7 @@
-
(
UIImagePickerController
*
)
imagePickerVc
{
if
(
_imagePickerVc
==
nil
)
{
_imagePickerVc
=
[[
UIImagePickerController
alloc
]
init
];
_imagePickerVc
.
delegate
=
self
;
_imagePickerVc
.
delegate
=
self
;
// *** 这句代码多余的????***
// set appearance / 改变相册选择页的导航栏外观
_imagePickerVc
.
navigationBar
.
barTintColor
=
self
.
navigationController
.
navigationBar
.
barTintColor
;
_imagePickerVc
.
navigationBar
.
tintColor
=
self
.
navigationController
.
navigationBar
.
tintColor
;
...
...
@@ -50,8 +50,11 @@
tzBarItem
=
[
UIBarButtonItem
appearanceWhenContainedInInstancesOfClasses
:@[[
TZImagePickerController
class
]]];
BarItem
=
[
UIBarButtonItem
appearanceWhenContainedInInstancesOfClasses
:@[[
UIImagePickerController
class
]]];
}
else
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
tzBarItem
=
[
UIBarButtonItem
appearanceWhenContainedIn
:[
TZImagePickerController
class
],
nil
];
BarItem
=
[
UIBarButtonItem
appearanceWhenContainedIn
:[
UIImagePickerController
class
],
nil
];
#pragma clang diagnostic pop
}
NSDictionary
*
titleTextAttributes
=
[
tzBarItem
titleTextAttributesForState
:
UIControlStateNormal
];
[
BarItem
setTitleTextAttributes
:
titleTextAttributes
forState
:
UIControlStateNormal
];
...
...
@@ -111,7 +114,10 @@
if
(
indexPath
.
row
==
_selectedPhotos
.
count
)
{
BOOL
showSheet
=
self
.
showSheetSwitch
.
isOn
;
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
];
#pragma clang diagnostic pop
[
sheet
showInView
:
self
.
view
];
}
else
{
[
self
pushImagePickerController
];
...
...
@@ -122,9 +128,12 @@
if
([
asset
isKindOfClass
:[
PHAsset
class
]])
{
PHAsset
*
phAsset
=
asset
;
isVideo
=
phAsset
.
mediaType
==
PHAssetMediaTypeVideo
;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
}
else
if
([
asset
isKindOfClass
:[
ALAsset
class
]])
{
ALAsset
*
alAsset
=
asset
;
isVideo
=
[[
alAsset
valueForProperty
:
ALAssetPropertyType
]
isEqualToString
:
ALAssetTypeVideo
];
#pragma clang diagnostic pop
}
if
(
isVideo
)
{
// perview video / 预览视频
TZVideoPlayerController
*
vc
=
[[
TZVideoPlayerController
alloc
]
init
];
...
...
@@ -201,8 +210,11 @@
AVAuthorizationStatus
authStatus
=
[
AVCaptureDevice
authorizationStatusForMediaType
:
AVMediaTypeVideo
];
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
];
[
alert
show
];
#define push @#clang diagnostic pop
}
else
{
// 调用相机
UIImagePickerControllerSourceType
sourceType
=
UIImagePickerControllerSourceTypeCamera
;
if
([
UIImagePickerController
isSourceTypeAvailable
:
UIImagePickerControllerSourceTypeCamera
])
{
...
...
@@ -249,7 +261,10 @@
#pragma mark - UIActionSheetDelegate
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
-
(
void
)
actionSheet
:(
UIActionSheet
*
)
actionSheet
clickedButtonAtIndex
:(
NSInteger
)
buttonIndex
{
#pragma clang diagnostic pop
if
(
buttonIndex
==
0
)
{
// take photo / 去拍照
[
self
takePhoto
];
}
else
if
(
buttonIndex
==
1
)
{
...
...
@@ -259,7 +274,10 @@
#pragma mark - UIAlertViewDelegate
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
-
(
void
)
alertView
:(
UIAlertView
*
)
alertView
clickedButtonAtIndex
:(
NSInteger
)
buttonIndex
{
#pragma clang diagnostic pop
if
(
buttonIndex
==
1
)
{
// 去设置界面,开启相机访问权限
if
(
iOS8Later
)
{
[[
UIApplication
sharedApplication
]
openURL
:[
NSURL
URLWithString
:
UIApplicationOpenSettingsURLString
]];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment