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
24c15c96
Commit
24c15c96
authored
Jan 31, 2020
by
yuzheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove UIAlertView
parent
8cb02729
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
37 deletions
+22
-37
TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m
...troller/TZImagePickerController/TZPhotoPickerController.m
+9
-24
TZImagePickerController/ViewController.m
TZImagePickerController/ViewController.m
+13
-13
No files found.
TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m
View file @
24c15c96
...
...
@@ -19,7 +19,7 @@
#import <MobileCoreServices/MobileCoreServices.h>
#import "TZImageRequestOperation.h"
@interface
TZPhotoPickerController
()
<
UICollectionViewDataSource
,
UICollectionViewDelegate
,
UIImagePickerControllerDelegate
,
UINavigationControllerDelegate
,
UIAlertViewDelegate
>
{
@interface
TZPhotoPickerController
()
<
UICollectionViewDataSource
,
UICollectionViewDelegate
,
UIImagePickerControllerDelegate
,
UINavigationControllerDelegate
>
{
NSMutableArray
*
_models
;
UIView
*
_bottomToolBar
;
...
...
@@ -650,21 +650,14 @@ static CGFloat itemMargin = 5;
NSString
*
title
=
[
NSBundle
tz_localizedStringForKey
:
@"Can not use camera"
];
NSString
*
message
=
[
NSString
stringWithFormat
:[
NSBundle
tz_localizedStringForKey
:
@"Please allow %@ to access your camera in
\"
Settings -> Privacy -> Camera
\"
"
],
appName
];
if
(
@available
(
iOS
8
,
*
))
{
UIAlertController
*
alertController
=
[
UIAlertController
alertControllerWithTitle
:
title
message
:
message
preferredStyle
:
UIAlertControllerStyleAlert
];
UIAlertAction
*
cancelAct
=
[
UIAlertAction
actionWithTitle
:[
NSBundle
tz_localizedStringForKey
:
@"Cancel"
]
style
:
UIAlertActionStyleCancel
handler
:
nil
];
[
alertController
addAction
:
cancelAct
];
UIAlertAction
*
settingAct
=
[
UIAlertAction
actionWithTitle
:[
NSBundle
tz_localizedStringForKey
:
@"Setting"
]
style
:
UIAlertActionStyleDefault
handler
:^
(
UIAlertAction
*
_Nonnull
action
)
{
[[
UIApplication
sharedApplication
]
openURL
:[
NSURL
URLWithString
:
UIApplicationOpenSettingsURLString
]];
[
alertController
dismissViewControllerAnimated
:
YES
completion
:
nil
];
}];
[
alertController
addAction
:
settingAct
];
TZImagePickerController
*
tzImagePickerVc
=
(
TZImagePickerController
*
)
self
.
navigationController
;
[
tzImagePickerVc
presentViewController
:
alertController
animated
:
YES
completion
:
nil
];
}
else
{
UIAlertView
*
alert
=
[[
UIAlertView
alloc
]
initWithTitle
:
title
message
:
message
delegate
:
self
cancelButtonTitle
:
[
NSBundle
tz_localizedStringForKey
:
@"Cancel"
]
otherButtonTitles
:
[
NSBundle
tz_localizedStringForKey
:
@"Setting"
],
nil
];
[
alert
show
];
}
[
self
.
navigationController
presentViewController
:
alertController
animated
:
YES
completion
:
nil
];
}
else
if
(
authStatus
==
AVAuthorizationStatusNotDetermined
)
{
// fix issue 466, 防止用户首次拍照拒绝授权时相机页黑屏
[
AVCaptureDevice
requestAccessForMediaType
:
AVMediaTypeVideo
completionHandler
:
^
(
BOOL
granted
)
{
...
...
@@ -809,14 +802,6 @@ static CGFloat itemMargin = 5;
}
}
#pragma mark - UIAlertViewDelegate
-
(
void
)
alertView
:(
UIAlertView
*
)
alertView
clickedButtonAtIndex
:(
NSInteger
)
buttonIndex
{
if
(
buttonIndex
==
1
)
{
// 去设置界面,开启相机访问权限
[[
UIApplication
sharedApplication
]
openURL
:[
NSURL
URLWithString
:
UIApplicationOpenSettingsURLString
]];
}
}
#pragma mark - UIImagePickerControllerDelegate
-
(
void
)
imagePickerController
:(
UIImagePickerController
*
)
picker
didFinishPickingMediaWithInfo
:(
NSDictionary
*
)
info
{
...
...
TZImagePickerController/ViewController.m
View file @
24c15c96
...
...
@@ -22,7 +22,7 @@
#import "FLAnimatedImage.h"
#import "TZImageUploadOperation.h"
@interface
ViewController
()
<
TZImagePickerControllerDelegate
,
UICollectionViewDataSource
,
UICollectionViewDelegate
,
UIImagePickerControllerDelegate
,
UI
AlertViewDelegate
,
UI
NavigationControllerDelegate
>
{
@interface
ViewController
()
<
TZImagePickerControllerDelegate
,
UICollectionViewDataSource
,
UICollectionViewDelegate
,
UIImagePickerControllerDelegate
,
UINavigationControllerDelegate
>
{
NSMutableArray
*
_selectedPhotos
;
NSMutableArray
*
_selectedAssets
;
BOOL
_isSelectOriginalPhoto
;
...
...
@@ -409,8 +409,12 @@
AVAuthorizationStatus
authStatus
=
[
AVCaptureDevice
authorizationStatusForMediaType
:
AVMediaTypeVideo
];
if
(
authStatus
==
AVAuthorizationStatusRestricted
||
authStatus
==
AVAuthorizationStatusDenied
)
{
// 无相机权限 做一个友好的提示
UIAlertView
*
alert
=
[[
UIAlertView
alloc
]
initWithTitle
:
@"无法使用相机"
message
:
@"请在iPhone的""设置-隐私-相机""中允许访问相机"
delegate
:
self
cancelButtonTitle
:
@"取消"
otherButtonTitles
:
@"设置"
,
nil
];
[
alert
show
];
UIAlertController
*
alertController
=
[
UIAlertController
alertControllerWithTitle
:
@"无法使用相机"
message
:
@"请在iPhone的""设置-隐私-相机""中允许访问相机"
preferredStyle
:
UIAlertControllerStyleAlert
];
[
alertController
addAction
:[
UIAlertAction
actionWithTitle
:
@"取消"
style
:
UIAlertActionStyleCancel
handler
:
nil
]];
[
alertController
addAction
:[
UIAlertAction
actionWithTitle
:
@"设置"
style
:
UIAlertActionStyleDefault
handler
:
^
(
UIAlertAction
*
_Nonnull
action
)
{
[[
UIApplication
sharedApplication
]
openURL
:[
NSURL
URLWithString
:
UIApplicationOpenSettingsURLString
]];
}]];
[
self
presentViewController
:
alertController
animated
:
YES
completion
:
nil
];
}
else
if
(
authStatus
==
AVAuthorizationStatusNotDetermined
)
{
// fix issue 466, 防止用户首次拍照拒绝授权时相机页黑屏
[
AVCaptureDevice
requestAccessForMediaType
:
AVMediaTypeVideo
completionHandler
:
^
(
BOOL
granted
)
{
...
...
@@ -422,8 +426,12 @@
}];
// 拍照之前还需要检查相册权限
}
else
if
([
PHPhotoLibrary
authorizationStatus
]
==
2
)
{
// 已被拒绝,没有相册权限,将无法保存拍的照片
UIAlertView
*
alert
=
[[
UIAlertView
alloc
]
initWithTitle
:
@"无法访问相册"
message
:
@"请在iPhone的""设置-隐私-相册""中允许访问相册"
delegate
:
self
cancelButtonTitle
:
@"取消"
otherButtonTitles
:
@"设置"
,
nil
];
[
alert
show
];
UIAlertController
*
alertController
=
[
UIAlertController
alertControllerWithTitle
:
@"无法访问相册"
message
:
@"请在iPhone的""设置-隐私-相册""中允许访问相册"
preferredStyle
:
UIAlertControllerStyleAlert
];
[
alertController
addAction
:[
UIAlertAction
actionWithTitle
:
@"取消"
style
:
UIAlertActionStyleCancel
handler
:
nil
]];
[
alertController
addAction
:[
UIAlertAction
actionWithTitle
:
@"设置"
style
:
UIAlertActionStyleDefault
handler
:
^
(
UIAlertAction
*
_Nonnull
action
)
{
[[
UIApplication
sharedApplication
]
openURL
:[
NSURL
URLWithString
:
UIApplicationOpenSettingsURLString
]];
}]];
[
self
presentViewController
:
alertController
animated
:
YES
completion
:
nil
];
}
else
if
([
PHPhotoLibrary
authorizationStatus
]
==
0
)
{
// 未请求过相册权限
[[
TZImageManager
manager
]
requestAuthorizationWithCompletion
:
^
{
[
self
takePhoto
];
...
...
@@ -529,14 +537,6 @@
}
}
#pragma mark - UIAlertViewDelegate
-
(
void
)
alertView
:(
UIAlertView
*
)
alertView
clickedButtonAtIndex
:(
NSInteger
)
buttonIndex
{
if
(
buttonIndex
==
1
)
{
// 去设置界面,开启相机访问权限
[[
UIApplication
sharedApplication
]
openURL
:[
NSURL
URLWithString
:
UIApplicationOpenSettingsURLString
]];
}
}
#pragma mark - TZImagePickerControllerDelegate
/// User click cancel button
...
...
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