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
15cd397c
Commit
15cd397c
authored
Oct 14, 2024
by
Alex朱枝文
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
解决文件查看工具可能出现崩溃的问题
https://bugly.qq.com/v2/crash-reporting/crashes/5dc2acc53e?pid=2
parent
adcd4459
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
7 deletions
+17
-7
YHFilePreviewTool.swift
...ice(服务中心)/MyCertificates(我的证书)/VM/YHFilePreviewTool.swift
+17
-7
No files found.
galaxy/galaxy/Classes/Modules/IntelligentService(服务中心)/MyCertificates(我的证书)/VM/YHFilePreviewTool.swift
View file @
15cd397c
...
...
@@ -10,9 +10,10 @@ import UIKit
class
YHFilePreviewTool
:
NSObject
{
weak
var
targetVC
:
UIViewController
!
weak
var
targetVC
:
UIViewController
?
private
var
documentController
:
UIDocumentInteractionController
?
init
(
targetVC
:
UIViewController
!
)
{
init
(
targetVC
:
UIViewController
?
)
{
self
.
targetVC
=
targetVC
}
...
...
@@ -50,13 +51,22 @@ class YHFilePreviewTool: NSObject {
}
func
openXLSXFile
(
at
fileURL
:
URL
,
fileName
:
String
?)
{
let
c
ontroller
=
UIDocumentInteractionController
(
url
:
fileURL
)
documentC
ontroller
=
UIDocumentInteractionController
(
url
:
fileURL
)
// 设置标题显示
if
let
fileName
=
fileName
,
!
fileName
.
isEmpty
{
controller
.
name
=
fileName
documentController
?
.
name
=
fileName
}
controller
.
delegate
=
self
DispatchQueue
.
main
.
async
{
documentController
?
.
delegate
=
self
guard
let
controller
=
documentController
else
{
printLog
(
"Failed to create UIDocumentInteractionController"
)
return
}
DispatchQueue
.
main
.
async
{
[
weak
self
]
in
guard
let
self
=
self
,
let
presentingVC
=
self
.
targetVC
else
{
printLog
(
"Target view controller is not available"
)
return
}
controller
.
presentPreview
(
animated
:
true
)
}
}
...
...
@@ -64,6 +74,6 @@ class YHFilePreviewTool: NSObject {
extension
YHFilePreviewTool
:
UIDocumentInteractionControllerDelegate
{
func
documentInteractionControllerViewControllerForPreview
(
_
controller
:
UIDocumentInteractionController
)
->
UIViewController
{
return
targetVC
return
targetVC
??
UIViewController
.
current
??
UIViewController
()
}
}
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