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
c49d55cf
Commit
c49d55cf
authored
Aug 12, 2016
by
Zhen Tan
Committed by
GitHub
Aug 12, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #164 from bringbird/master
消除因适配不同系统版本调用过期API的警告
parents
0ad0c02f
0de5bea9
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
123 additions
and
2 deletions
+123
-2
TZImagePickerController/TZImagePickerController/TZImageManager.m
...PickerController/TZImagePickerController/TZImageManager.m
+79
-1
TZImagePickerController/TZImagePickerController/TZImagePickerController.m
...troller/TZImagePickerController/TZImagePickerController.m
+13
-0
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 @
c49d55cf
This diff is collapsed.
Click to expand it.
TZImagePickerController/TZImagePickerController/TZImagePickerController.m
View file @
c49d55cf
...
...
@@ -52,7 +52,10 @@
if
(
iOS9Later
)
{
barItem
=
[
UIBarButtonItem
appearanceWhenContainedInInstancesOfClasses
:@[[
TZImagePickerController
class
]]];
}
else
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
barItem
=
[
UIBarButtonItem
appearanceWhenContainedIn
:[
TZImagePickerController
class
],
nil
];
#pragma clang diagnostic pop
}
NSMutableDictionary
*
textAttrs
=
[
NSMutableDictionary
dictionary
];
textAttrs
[
NSForegroundColorAttributeName
]
=
[
UIColor
whiteColor
];
...
...
@@ -63,7 +66,10 @@
-
(
void
)
viewWillAppear
:(
BOOL
)
animated
{
[
super
viewWillAppear
:
animated
];
_originStatusBarStyle
=
[
UIApplication
sharedApplication
].
statusBarStyle
;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[
UIApplication
sharedApplication
].
statusBarStyle
=
iOS7Later
?
UIStatusBarStyleLightContent
:
UIStatusBarStyleBlackOpaque
;
#pragma clang diagnostic pop
}
-
(
void
)
viewWillDisappear
:(
BOOL
)
animated
{
...
...
@@ -164,7 +170,10 @@
[
alertController
addAction
:[
UIAlertAction
actionWithTitle
:
@"我知道了"
style
:
UIAlertActionStyleDefault
handler
:
nil
]];
[
self
presentViewController
:
alertController
animated
:
YES
completion
:
nil
];
}
else
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[[[
UIAlertView
alloc
]
initWithTitle
:
title
message
:
nil
delegate
:
nil
cancelButtonTitle
:
@"我知道了"
otherButtonTitles
:
nil
,
nil
]
show
];
#pragma clang diagnostic pop
}
}
...
...
@@ -270,7 +279,11 @@
backButton
.
titleLabel
.
font
=
[
UIFont
systemFontOfSize
:
15
];
[
backButton
addTarget
:
self
action
:
@selector
(
popViewControllerAnimated
:
)
forControlEvents
:
UIControlEventTouchUpInside
];
UIBarButtonItem
*
backButtonItem
=
[[
UIBarButtonItem
alloc
]
initWithCustomView
:
backButton
];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
backButtonItem
.
style
=
UIBarButtonItemStyleBordered
;
#pragma clang diagnostic pop
self
.
topViewController
.
navigationItem
.
backBarButtonItem
=
backButtonItem
;
/**
...
...
TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m
View file @
c49d55cf
...
...
@@ -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 @
c49d55cf
...
...
@@ -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 @
c49d55cf
...
...
@@ -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