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
Expand all
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
This diff is collapsed.
Click to expand it.
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