Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
galaxy-iOS
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mobile-group
galaxy-iOS
Commits
0ceb7101
Commit
0ceb7101
authored
Apr 18, 2024
by
Steven杜宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
// 权限
parent
4b4e94a0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
13 deletions
+39
-13
YHMyPermissionSettingVC.swift
.../Classes/Modules/Mine(我的)/C/YHMyPermissionSettingVC.swift
+39
-13
No files found.
galaxy/galaxy/Classes/Modules/Mine(我的)/C/YHMyPermissionSettingVC.swift
View file @
0ceb7101
...
@@ -90,6 +90,13 @@ class YHMyPermissionSettingVC: YHBaseViewController {
...
@@ -90,6 +90,13 @@ class YHMyPermissionSettingVC: YHBaseViewController {
updateNetWorkStatus
()
updateNetWorkStatus
()
// 2)获取相册权限
// 2)获取相册权限
requestAndUpdatePhotoPermission
()
// 3)获取相机权限
requestAndUpdateCameraPermission
()
}
func
requestAndUpdatePhotoPermission
()
{
requestPhotoLibraryPermission
{
requestPhotoLibraryPermission
{
[
weak
self
]
grant
in
[
weak
self
]
grant
in
guard
let
self
=
self
else
{
return
}
guard
let
self
=
self
else
{
return
}
...
@@ -102,8 +109,9 @@ class YHMyPermissionSettingVC: YHBaseViewController {
...
@@ -102,8 +109,9 @@ class YHMyPermissionSettingVC: YHBaseViewController {
}
}
}
}
}
}
}
// 3)获取相机权限
func
requestAndUpdateCameraPermission
()
{
requestCameraPermission
{
requestCameraPermission
{
[
weak
self
]
grant
in
[
weak
self
]
grant
in
guard
let
self
=
self
else
{
return
}
guard
let
self
=
self
else
{
return
}
...
@@ -132,13 +140,7 @@ class YHMyPermissionSettingVC: YHBaseViewController {
...
@@ -132,13 +140,7 @@ class YHMyPermissionSettingVC: YHBaseViewController {
case
.
notDetermined
:
case
.
notDetermined
:
// 尚未确定,请求授权
// 尚未确定,请求授权
PHPhotoLibrary
.
requestAuthorization
{
completion
(
false
)
authorizationStatus
in
self
.
requestPhotoLibraryPermission
{
granted
in
completion
(
granted
)
}
}
@unknown
default
:
@unknown
default
:
completion
(
false
)
completion
(
false
)
...
@@ -159,10 +161,7 @@ class YHMyPermissionSettingVC: YHBaseViewController {
...
@@ -159,10 +161,7 @@ class YHMyPermissionSettingVC: YHBaseViewController {
case
.
notDetermined
:
case
.
notDetermined
:
// 尚未确定,请求授权
// 尚未确定,请求授权
AVCaptureDevice
.
requestAccess
(
for
:
.
video
)
{
completion
(
false
)
granted
in
completion
(
granted
)
}
@unknown
default
:
@unknown
default
:
completion
(
false
)
completion
(
false
)
...
@@ -195,7 +194,33 @@ extension YHMyPermissionSettingVC: UITableViewDelegate, UITableViewDataSource {
...
@@ -195,7 +194,33 @@ extension YHMyPermissionSettingVC: UITableViewDelegate, UITableViewDataSource {
}
}
func
tableView
(
_
tableView
:
UITableView
,
didSelectRowAt
indexPath
:
IndexPath
)
{
func
tableView
(
_
tableView
:
UITableView
,
didSelectRowAt
indexPath
:
IndexPath
)
{
if
0
<=
indexPath
.
row
&&
indexPath
.
row
<
items
.
count
{
let
item
=
items
[
indexPath
.
row
]
if
item
.
type
==
.
photo
{
let
status
=
PHPhotoLibrary
.
authorizationStatus
()
if
status
==
.
notDetermined
{
PHPhotoLibrary
.
requestAuthorization
{
authorizationStatus
in
self
.
requestPhotoLibraryPermission
{
[
weak
self
]
granted
in
guard
let
self
=
self
else
{
return
}
requestAndUpdatePhotoPermission
()
}
}
return
}
}
if
item
.
type
==
.
camera
{
let
status
=
AVCaptureDevice
.
authorizationStatus
(
for
:
.
video
)
if
status
==
.
notDetermined
{
AVCaptureDevice
.
requestAccess
(
for
:
.
video
)
{
[
weak
self
]
granted
in
guard
let
self
=
self
else
{
return
}
requestAndUpdateCameraPermission
()
}
return
}
}
let
url
=
URL
(
string
:
UIApplication
.
openSettingsURLString
)
let
url
=
URL
(
string
:
UIApplication
.
openSettingsURLString
)
if
let
url
=
url
,
UIApplication
.
shared
.
canOpenURL
(
url
)
{
if
let
url
=
url
,
UIApplication
.
shared
.
canOpenURL
(
url
)
{
printLog
(
"settingUrl:
\(
url
)
"
)
printLog
(
"settingUrl:
\(
url
)
"
)
...
@@ -204,6 +229,7 @@ extension YHMyPermissionSettingVC: UITableViewDelegate, UITableViewDataSource {
...
@@ -204,6 +229,7 @@ extension YHMyPermissionSettingVC: UITableViewDelegate, UITableViewDataSource {
})
})
}
}
}
}
}
private
func
tableView
(
_
tableView
:
UITableView
,
viewForHeaderInSection
section
:
Int
)
->
CGFloat
{
private
func
tableView
(
_
tableView
:
UITableView
,
viewForHeaderInSection
section
:
Int
)
->
CGFloat
{
return
UITableView
.
automaticDimension
return
UITableView
.
automaticDimension
...
...
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