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
a4a50f0b
Commit
a4a50f0b
authored
Mar 07, 2024
by
pete谢兆麟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
工作经验相关bug修复
parent
e750b383
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
62 additions
and
60 deletions
+62
-60
YHHomeViewController.swift
...axy/Classes/Modules/Home(首页)/C/YHHomeViewController.swift
+2
-2
YHCompanySelectViewController.swift
...orkExperience(工作经验)/C/YHCompanySelectViewController.swift
+4
-3
YHWorkExperienceViewController.swift
...rkExperience(工作经验)/C/YHWorkExperienceViewController.swift
+5
-0
YHWorkExperienceItemView.swift
...流程)/WorkExperience(工作经验)/V/YHWorkExperienceItemView.swift
+7
-5
YHWorkExperienceTableViewCell.swift
...orkExperience(工作经验)/V/YHWorkExperienceTableViewCell.swift
+8
-0
YHWorkHighlightsTableViewCell.swift
...orkExperience(工作经验)/V/YHWorkHighlightsTableViewCell.swift
+1
-1
YHWorkExperienceViewModel.swift
...xperience(工作经验)/ViewModel/YHWorkExperienceViewModel.swift
+10
-4
YHNewWebViewController.swift
.../Classes/Modules/Login(登录)/C/YHNewWebViewController.swift
+25
-45
No files found.
galaxy/galaxy/Classes/Modules/Home(首页)/C/YHHomeViewController.swift
View file @
a4a50f0b
...
@@ -401,8 +401,8 @@ extension YHHomeViewController : UITableViewDelegate,UITableViewDataSource {
...
@@ -401,8 +401,8 @@ extension YHHomeViewController : UITableViewDelegate,UITableViewDataSource {
func
tableView
(
_
tableView
:
UITableView
,
didSelectRowAt
indexPath
:
IndexPath
)
{
func
tableView
(
_
tableView
:
UITableView
,
didSelectRowAt
indexPath
:
IndexPath
)
{
tableView
.
deselectRow
(
at
:
indexPath
,
animated
:
true
)
tableView
.
deselectRow
(
at
:
indexPath
,
animated
:
true
)
printLog
(
"点击了 tableView Cell
\(
indexPath
.
row
)
"
)
printLog
(
"点击了 tableView Cell
\(
indexPath
.
row
)
"
)
let
vc
=
YH
WebView
ViewController
()
let
vc
=
YH
NewWeb
ViewController
()
vc
.
url
=
"https://cloudapi.qiyuesuo.cn/contract/share/320
2449385770287813?openPageToken=dd333ac2-88cd-40f8-b985-dc00c7c2f90a
"
vc
.
url
=
"https://cloudapi.qiyuesuo.cn/contract/share/320
3196638675878889?openPageToken=1c9e8a62-eeb5-4651-9a13-adf335ae3dbe
"
self
.
navigationController
?
.
pushViewController
(
vc
)
self
.
navigationController
?
.
pushViewController
(
vc
)
// https://cloudapi.qiyuesuo.cn/contract/share/3202449385770287813?openPageToken=d004e5af-aab9-43e4-b813-c5a6a8c16497
// https://cloudapi.qiyuesuo.cn/contract/share/3202449385770287813?openPageToken=d004e5af-aab9-43e4-b813-c5a6a8c16497
}
}
...
...
galaxy/galaxy/Classes/Modules/IntelligentService(服务中心)/ServiceProcess(流程)/WorkExperience(工作经验)/C/YHCompanySelectViewController.swift
View file @
a4a50f0b
...
@@ -10,7 +10,7 @@ import UIKit
...
@@ -10,7 +10,7 @@ import UIKit
class
YHCompanySelectViewController
:
YHBaseViewController
{
class
YHCompanySelectViewController
:
YHBaseViewController
{
public
var
backLocationStringController
:
((
String
)
->
Void
)?
public
var
backLocationStringController
:
((
YHCompanyModelListModel
)
->
Void
)?
var
searchView
:
UITextField
!
var
searchView
:
UITextField
!
var
sureButton
:
UIButton
!
var
sureButton
:
UIButton
!
var
tableView
:
UITableView
!
var
tableView
:
UITableView
!
...
@@ -130,7 +130,8 @@ class YHCompanySelectViewController: YHBaseViewController {
...
@@ -130,7 +130,8 @@ class YHCompanySelectViewController: YHBaseViewController {
@objc
func
submit
()
{
@objc
func
submit
()
{
if
let
backLocationStringController
=
backLocationStringController
{
if
let
backLocationStringController
=
backLocationStringController
{
backLocationStringController
(
searchView
.
text
??
""
)
var
model
=
YHCompanyModelListModel
()
model
.
company_name
=
searchView
.
text
self
.
navigationController
?
.
popViewController
()
self
.
navigationController
?
.
popViewController
()
}
}
}
}
...
@@ -182,7 +183,7 @@ extension YHCompanySelectViewController: UITableViewDelegate, UITableViewDataSou
...
@@ -182,7 +183,7 @@ extension YHCompanySelectViewController: UITableViewDelegate, UITableViewDataSou
}
}
func
tableView
(
_
tableView
:
UITableView
,
didSelectRowAt
indexPath
:
IndexPath
)
{
func
tableView
(
_
tableView
:
UITableView
,
didSelectRowAt
indexPath
:
IndexPath
)
{
let
text
=
searchDataSource
?[
indexPath
.
row
]
.
company_name
??
""
guard
let
text
=
searchDataSource
?[
indexPath
.
row
]
else
{
return
}
if
let
backLocationStringController
=
backLocationStringController
{
if
let
backLocationStringController
=
backLocationStringController
{
backLocationStringController
(
text
)
backLocationStringController
(
text
)
self
.
navigationController
?
.
popViewController
()
self
.
navigationController
?
.
popViewController
()
...
...
galaxy/galaxy/Classes/Modules/IntelligentService(服务中心)/ServiceProcess(流程)/WorkExperience(工作经验)/C/YHWorkExperienceViewController.swift
View file @
a4a50f0b
...
@@ -453,6 +453,11 @@ extension YHWorkExperienceViewController: UITableViewDelegate, UITableViewDataSo
...
@@ -453,6 +453,11 @@ extension YHWorkExperienceViewController: UITableViewDelegate, UITableViewDataSo
self
.
updateDataSource
()
self
.
updateDataSource
()
}
}
}
}
cell
.
companyBlock
=
{[
weak
self
]
company
in
guard
let
self
=
self
else
{
return
}
self
.
viewModel
.
updateModel
(
company
)
self
.
updateDataSource
()
}
return
cell
return
cell
}
}
}
}
...
...
galaxy/galaxy/Classes/Modules/IntelligentService(服务中心)/ServiceProcess(流程)/WorkExperience(工作经验)/V/YHWorkExperienceItemView.swift
View file @
a4a50f0b
...
@@ -10,7 +10,9 @@ import UIKit
...
@@ -10,7 +10,9 @@ import UIKit
class
YHWorkExperienceItemView
:
UIView
{
class
YHWorkExperienceItemView
:
UIView
{
typealias
ItemBlock
=
(
_
model
:
YHWorkExperienceModel
)
->
()
typealias
ItemBlock
=
(
_
model
:
YHWorkExperienceModel
)
->
()
typealias
CompanyBlock
=
(
_
model
:
YHCompanyModelListModel
)
->
()
var
block
:
ItemBlock
?
var
block
:
ItemBlock
?
var
companyBlock
:
CompanyBlock
?
var
titleLabel
:
UILabel
!
var
titleLabel
:
UILabel
!
var
messageTextField
:
UITextField
!
var
messageTextField
:
UITextField
!
var
nextStepImageView
:
UIImageView
!
var
nextStepImageView
:
UIImageView
!
...
@@ -279,7 +281,7 @@ class YHWorkExperienceItemView: UIView {
...
@@ -279,7 +281,7 @@ class YHWorkExperienceItemView: UIView {
showPromptLabel
.
isHidden
=
true
showPromptLabel
.
isHidden
=
true
}
}
if
dataSource
.
id
==
.
id10
{
if
dataSource
.
id
==
.
id10
||
dataSource
.
id
==
.
id22
{
longTimeButton
.
isHidden
=
false
longTimeButton
.
isHidden
=
false
nextStepImageView
.
isHidden
=
true
nextStepImageView
.
isHidden
=
true
if
dataSource
.
message
==
"至今"
{
if
dataSource
.
message
==
"至今"
{
...
@@ -371,7 +373,7 @@ class YHWorkExperienceItemView: UIView {
...
@@ -371,7 +373,7 @@ class YHWorkExperienceItemView: UIView {
case
.
normal
:
case
.
normal
:
printLog
(
"不需要跳转"
)
printLog
(
"不需要跳转"
)
case
.
address
:
case
.
address
:
let
addressPicker
=
YHAddressViewController
(
selectProvince
:
"上海市"
,
selectCity
:
""
)
let
addressPicker
=
YHAddressViewController
()
addressPicker
.
backLocationStringController
=
{
(
address
,
province
,
city
,
area
)
in
addressPicker
.
backLocationStringController
=
{
(
address
,
province
,
city
,
area
)
in
self
.
dataSource
?
.
message
=
address
self
.
dataSource
?
.
message
=
address
self
.
dataSource
?
.
value
=
[
province
,
city
,
area
]
self
.
dataSource
?
.
value
=
[
province
,
city
,
area
]
...
@@ -409,10 +411,10 @@ class YHWorkExperienceItemView: UIView {
...
@@ -409,10 +411,10 @@ class YHWorkExperienceItemView: UIView {
case
.
unit
:
case
.
unit
:
let
vc
=
YHCompanySelectViewController
()
let
vc
=
YHCompanySelectViewController
()
vc
.
backLocationStringController
=
{
(
country
)
in
vc
.
backLocationStringController
=
{
(
country
)
in
self
.
dataSource
?
.
message
=
country
self
.
dataSource
?
.
message
=
country
.
company_name
self
.
updateAllViews
()
self
.
updateAllViews
()
if
let
block
=
self
.
b
lock
{
if
let
block
=
self
.
companyB
lock
{
block
(
self
.
dataSource
??
YHWorkExperienceModel
()
)
block
(
country
)
}
}
}
}
UIViewController
.
current
?
.
navigationController
?
.
pushViewController
(
vc
)
UIViewController
.
current
?
.
navigationController
?
.
pushViewController
(
vc
)
...
...
galaxy/galaxy/Classes/Modules/IntelligentService(服务中心)/ServiceProcess(流程)/WorkExperience(工作经验)/V/YHWorkExperienceTableViewCell.swift
View file @
a4a50f0b
...
@@ -10,6 +10,8 @@ import UIKit
...
@@ -10,6 +10,8 @@ import UIKit
class
YHWorkExperienceTableViewCell
:
UITableViewCell
{
class
YHWorkExperienceTableViewCell
:
UITableViewCell
{
typealias
WorkExperienceBlock
=
(
_
model
:
YHWorkExperienceModel
)
->
()
typealias
WorkExperienceBlock
=
(
_
model
:
YHWorkExperienceModel
)
->
()
typealias
CompanyBlock
=
(
_
model
:
YHCompanyModelListModel
)
->
()
var
companyBlock
:
CompanyBlock
?
var
workExperienceBlock
:
WorkExperienceBlock
?
var
workExperienceBlock
:
WorkExperienceBlock
?
var
centerView
:
UIView
!
var
centerView
:
UIView
!
var
titleLabel
:
UILabel
!
var
titleLabel
:
UILabel
!
...
@@ -138,6 +140,12 @@ class YHWorkExperienceTableViewCell: UITableViewCell {
...
@@ -138,6 +140,12 @@ class YHWorkExperienceTableViewCell: UITableViewCell {
block
(
model
)
block
(
model
)
}
}
}
}
itemView
.
companyBlock
=
{[
weak
self
]
company
in
guard
let
self
=
self
else
{
return
}
if
let
block
=
self
.
companyBlock
{
block
(
company
)
}
}
mainItemView
.
addSubview
(
itemView
)
mainItemView
.
addSubview
(
itemView
)
itemView
.
snp
.
makeConstraints
{
make
in
itemView
.
snp
.
makeConstraints
{
make
in
make
.
left
.
equalTo
(
18
)
make
.
left
.
equalTo
(
18
)
...
...
galaxy/galaxy/Classes/Modules/IntelligentService(服务中心)/ServiceProcess(流程)/WorkExperience(工作经验)/V/YHWorkHighlightsTableViewCell.swift
View file @
a4a50f0b
...
@@ -125,7 +125,7 @@ class YHWorkHighlightsTableViewCell: UITableViewCell {
...
@@ -125,7 +125,7 @@ class YHWorkHighlightsTableViewCell: UITableViewCell {
make
.
left
.
equalTo
(
18
)
make
.
left
.
equalTo
(
18
)
make
.
right
.
equalTo
(
-
18
)
make
.
right
.
equalTo
(
-
18
)
make
.
top
.
equalTo
(
111
)
make
.
top
.
equalTo
(
111
)
make
.
bottom
.
equalTo
(
-
44
)
make
.
bottom
.
equalTo
(
-
92
)
}
}
promptsLabel
=
{
promptsLabel
=
{
...
...
galaxy/galaxy/Classes/Modules/IntelligentService(服务中心)/ServiceProcess(流程)/WorkExperience(工作经验)/ViewModel/YHWorkExperienceViewModel.swift
View file @
a4a50f0b
...
@@ -22,14 +22,14 @@ class YHWorkExperienceViewModel: YHBaseViewModel {
...
@@ -22,14 +22,14 @@ class YHWorkExperienceViewModel: YHBaseViewModel {
let
item1
=
YHWorkExperienceModel
(
id
:
.
id2
,
isNeed
:
true
,
title
:
"用人单位性质"
,
isUserKeyBoard
:
false
,
prompts
:
"请输入"
,
message
:
mainModel
.
industry
,
type
:
.
nature
,
isShowPrompts
:
isShowPrompt
,
alertMessage
:
"请选择用人单位性质"
)
let
item1
=
YHWorkExperienceModel
(
id
:
.
id2
,
isNeed
:
true
,
title
:
"用人单位性质"
,
isUserKeyBoard
:
false
,
prompts
:
"请输入"
,
message
:
mainModel
.
industry
,
type
:
.
nature
,
isShowPrompts
:
isShowPrompt
,
alertMessage
:
"请选择用人单位性质"
)
let
item2
=
YHWorkExperienceModel
(
id
:
.
id3
,
isNeed
:
false
,
title
:
"用人单位介绍"
,
isUserKeyBoard
:
true
,
prompts
:
"如方便提供,请填写"
,
message
:
mainModel
.
company_introduce
)
let
item2
=
YHWorkExperienceModel
(
id
:
.
id3
,
isNeed
:
false
,
title
:
"用人单位介绍"
,
isUserKeyBoard
:
true
,
prompts
:
"如方便提供,请填写"
,
message
:
mainModel
.
company_introduce
)
let
item3
=
YHWorkExperienceModel
(
id
:
.
id4
,
isNeed
:
false
,
title
:
"用人单位官网"
,
isUserKeyBoard
:
true
,
prompts
:
"如有,请输入官网链接"
,
message
:
mainModel
.
company_website
)
let
item3
=
YHWorkExperienceModel
(
id
:
.
id4
,
isNeed
:
false
,
title
:
"用人单位官网"
,
isUserKeyBoard
:
true
,
prompts
:
"如有,请输入官网链接"
,
message
:
mainModel
.
company_website
)
let
item4
=
YHWorkExperienceModel
(
id
:
.
id5
,
isNeed
:
true
,
title
:
"
出生
国家/地区"
,
isUserKeyBoard
:
false
,
prompts
:
"请选择"
,
message
:
mainModel
.
location
.
country
,
type
:
.
country
,
isShowPrompts
:
isShowPrompt
,
alertMessage
:
"请选择工作国家/地区"
)
let
item4
=
YHWorkExperienceModel
(
id
:
.
id5
,
isNeed
:
true
,
title
:
"
工作
国家/地区"
,
isUserKeyBoard
:
false
,
prompts
:
"请选择"
,
message
:
mainModel
.
location
.
country
,
type
:
.
country
,
isShowPrompts
:
isShowPrompt
,
alertMessage
:
"请选择工作国家/地区"
)
var
string
=
""
var
string
=
""
let
array
=
mainModel
.
location
.
area
let
array
=
mainModel
.
location
.
area
for
item
in
array
{
for
item
in
array
{
string
=
string
+
item
string
=
string
+
item
}
}
let
item5
=
YHWorkExperienceModel
(
id
:
.
id6
,
isNeed
:
true
,
title
:
"
出生
城市"
,
isUserKeyBoard
:
false
,
prompts
:
"请选择"
,
message
:
string
,
type
:
.
address
,
isShowPrompts
:
isShowPrompt
,
alertMessage
:
"请选择工作国家/地区"
)
let
item5
=
YHWorkExperienceModel
(
id
:
.
id6
,
isNeed
:
true
,
title
:
"
工作
城市"
,
isUserKeyBoard
:
false
,
prompts
:
"请选择"
,
message
:
string
,
type
:
.
address
,
isShowPrompts
:
isShowPrompt
,
alertMessage
:
"请选择工作国家/地区"
)
let
item55
=
YHWorkExperienceModel
(
id
:
.
id7
,
isNeed
:
true
,
title
:
"
出生
城市"
,
isUserKeyBoard
:
true
,
prompts
:
"请输入"
,
message
:
mainModel
.
location
.
foreign
,
isShowPrompts
:
isShowPrompt
,
alertMessage
:
"请输入工作国家/地区"
)
let
item55
=
YHWorkExperienceModel
(
id
:
.
id7
,
isNeed
:
true
,
title
:
"
工作
城市"
,
isUserKeyBoard
:
true
,
prompts
:
"请输入"
,
message
:
mainModel
.
location
.
foreign
,
isShowPrompts
:
isShowPrompt
,
alertMessage
:
"请输入工作国家/地区"
)
let
item6
=
YHWorkExperienceModel
(
id
:
.
id8
,
isNeed
:
true
,
title
:
"职位"
,
isUserKeyBoard
:
true
,
prompts
:
"请输入"
,
message
:
mainModel
.
position
,
isShowPrompts
:
isShowPrompt
,
alertMessage
:
"请输入职位"
)
let
item6
=
YHWorkExperienceModel
(
id
:
.
id8
,
isNeed
:
true
,
title
:
"职位"
,
isUserKeyBoard
:
true
,
prompts
:
"请输入"
,
message
:
mainModel
.
position
,
isShowPrompts
:
isShowPrompt
,
alertMessage
:
"请输入职位"
)
let
item7
=
YHWorkExperienceModel
(
id
:
.
id9
,
isNeed
:
true
,
title
:
"入职年月"
,
isUserKeyBoard
:
false
,
prompts
:
"请选择"
,
message
:
mainModel
.
entry_time
,
type
:
.
time
,
isShowPrompts
:
isShowPrompt
,
alertMessage
:
"请选择入职年月"
)
let
item7
=
YHWorkExperienceModel
(
id
:
.
id9
,
isNeed
:
true
,
title
:
"入职年月"
,
isUserKeyBoard
:
false
,
prompts
:
"请选择"
,
message
:
mainModel
.
entry_time
,
type
:
.
time
,
isShowPrompts
:
isShowPrompt
,
alertMessage
:
"请选择入职年月"
)
let
item8
=
YHWorkExperienceModel
(
id
:
.
id10
,
isNeed
:
true
,
title
:
"离职年月"
,
isUserKeyBoard
:
false
,
prompts
:
"请选择"
,
message
:
mainModel
.
departure_time
,
type
:
.
time
,
isShowPrompts
:
isShowPrompt
,
alertMessage
:
"请选择离职年月"
)
let
item8
=
YHWorkExperienceModel
(
id
:
.
id10
,
isNeed
:
true
,
title
:
"离职年月"
,
isUserKeyBoard
:
false
,
prompts
:
"请选择"
,
message
:
mainModel
.
departure_time
,
type
:
.
time
,
isShowPrompts
:
isShowPrompt
,
alertMessage
:
"请选择离职年月"
)
...
@@ -114,6 +114,12 @@ class YHWorkExperienceViewModel: YHBaseViewModel {
...
@@ -114,6 +114,12 @@ class YHWorkExperienceViewModel: YHBaseViewModel {
}
}
}
}
func
updateModel
(
_
item
:
YHCompanyModelListModel
)
{
mainModel
.
company_name
=
item
.
company_name
??
""
mainModel
.
company_introduce
=
item
.
company_introduce
??
""
mainModel
.
company_website
=
item
.
company_link
??
""
}
func
updateWduty
(
_
value
:
String
)
{
func
updateWduty
(
_
value
:
String
)
{
mainModel
.
wduty
=
value
mainModel
.
wduty
=
value
}
}
...
@@ -230,7 +236,7 @@ class YHWorkExperienceViewModel: YHBaseViewModel {
...
@@ -230,7 +236,7 @@ class YHWorkExperienceViewModel: YHBaseViewModel {
"position"
:
mainModel
.
position
,
"position"
:
mainModel
.
position
,
"professional_level"
:
mainModel
.
professional_level
,
"professional_level"
:
mainModel
.
professional_level
,
"professional_other"
:
mainModel
.
professional_other
,
"professional_other"
:
mainModel
.
professional_other
,
"projects"
:
mainModel
.
projects
,
"projects"
:
[]
,
"remark"
:
mainModel
.
remark
,
"remark"
:
mainModel
.
remark
,
"step"
:
mainModel
.
step
,
"step"
:
mainModel
.
step
,
"top_manager_end_at"
:
mainModel
.
top_manager_end_at
,
"top_manager_end_at"
:
mainModel
.
top_manager_end_at
,
...
...
galaxy/galaxy/Classes/Modules/Login(登录)/C/YHNewWebViewController.swift
View file @
a4a50f0b
...
@@ -11,7 +11,7 @@ import WebKit
...
@@ -11,7 +11,7 @@ import WebKit
class
YHNewWebViewController
:
YHBaseViewController
,
WKUIDelegate
,
WKNavigationDelegate
{
class
YHNewWebViewController
:
YHBaseViewController
,
WKUIDelegate
,
WKNavigationDelegate
{
var
web
v
iew
=
WKWebView
()
var
web
V
iew
=
WKWebView
()
var
progBar
=
UIProgressView
()
var
progBar
=
UIProgressView
()
var
url
=
"https://www.baidu.com"
var
url
=
"https://www.baidu.com"
...
@@ -21,36 +21,24 @@ class YHNewWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationDe
...
@@ -21,36 +21,24 @@ class YHNewWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationDe
gk_navShadowColor
=
.
clear
gk_navShadowColor
=
.
clear
gk_navigationBar
.
isHidden
=
true
gk_navigationBar
.
isHidden
=
true
// 创建wkwebview
// 创建wkwebview
web
v
iew
=
WKWebView
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
self
.
view
.
frame
.
width
,
height
:
self
.
view
.
frame
.
height
))
web
V
iew
=
WKWebView
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
self
.
view
.
frame
.
width
,
height
:
self
.
view
.
frame
.
height
))
webView
.
navigationDelegate
=
self
web
view
.
navigation
Delegate
=
self
web
View
.
ui
Delegate
=
self
// 创建网址
// 创建网址
let
url
=
NSURL
(
string
:
url
)
let
url
=
NSURL
(
string
:
url
)
// 创建请求
// 创建请求
let
request
=
NSURLRequest
(
url
:
url
!
as
URL
)
let
request
=
NSURLRequest
(
url
:
url
!
as
URL
)
// 加载请求
// 加载请求
web
v
iew
.
load
(
request
as
URLRequest
)
web
V
iew
.
load
(
request
as
URLRequest
)
// 添加wkwebview
// 添加wkwebview
self
.
view
.
addSubview
(
web
v
iew
)
self
.
view
.
addSubview
(
web
V
iew
)
// // 加载网页的进度条
// progBar = UIProgressView(frame: CGRect(x: 0, y: 0, width: self.view.frame.width, height: 30))
// progBar.progress = 0.0
// progBar.tintColor = UIColor.brandMainColor
// webview.addSubview(progBar)
// // 监听网页加载的进度
// webview.addObserver(self, forKeyPath: "estimatedProgress", options: .new, context: nil)
}
override
func
viewWillDisappear
(
_
animated
:
Bool
)
{
// webview.removeObserver(self, forKeyPath: "estimatedProgress")
}
}
// MARK: - WKNavigationDelegate
// MARK: - WKNavigationDelegate
func
webView
(
_
webView
:
WKWebView
,
didFinish
navigation
:
WKNavigation
!
)
{
func
webView
(
_
webView
:
WKWebView
,
didFinish
navigation
:
WKNavigation
!
)
{
self
.
navigationItem
.
title
=
web
v
iew
.
title
self
.
navigationItem
.
title
=
web
V
iew
.
title
}
}
// MARK: - WKUIDelegate
// MARK: - WKUIDelegate
...
@@ -58,7 +46,7 @@ class YHNewWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationDe
...
@@ -58,7 +46,7 @@ class YHNewWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationDe
func
webView
(
_
webView
:
WKWebView
,
createWebViewWith
configuration
:
WKWebViewConfiguration
,
for
navigationAction
:
WKNavigationAction
,
windowFeatures
:
WKWindowFeatures
)
->
WKWebView
?
{
func
webView
(
_
webView
:
WKWebView
,
createWebViewWith
configuration
:
WKWebViewConfiguration
,
for
navigationAction
:
WKNavigationAction
,
windowFeatures
:
WKWindowFeatures
)
->
WKWebView
?
{
// 实现非安全链接的跳转。如果目标主视图不为空,则允许导航
// 实现非安全链接的跳转。如果目标主视图不为空,则允许导航
if
!
(
navigationAction
.
targetFrame
?
.
isMainFrame
!=
nil
)
{
if
!
(
navigationAction
.
targetFrame
?
.
isMainFrame
!=
nil
)
{
web
v
iew
.
load
(
navigationAction
.
request
)
web
V
iew
.
load
(
navigationAction
.
request
)
}
}
return
nil
return
nil
}
}
...
@@ -72,38 +60,30 @@ class YHNewWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationDe
...
@@ -72,38 +60,30 @@ class YHNewWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationDe
self
.
present
(
alert
,
animated
:
true
,
completion
:
nil
)
self
.
present
(
alert
,
animated
:
true
,
completion
:
nil
)
}
}
func
webView
(
_
webView
:
WKWebView
,
decidePolicyFor
navigationAction
:
WKNavigationAction
,
decisionHandler
:
@escaping
(
WKNavigationActionPolicy
)
->
Void
)
{
decisionHandler
(
.
allow
)
}
func
webView
(
_
webView
:
WKWebView
,
didStartProvisionalNavigation
navigation
:
WKNavigation
!
)
{
print
(
"页面开始加载"
)
}
func
webView
(
_
webView
:
WKWebView
,
didCommit
navigation
:
WKNavigation
!
)
{
print
(
"页面提交"
)
}
// MARK: - webview function
// MARK: - webview function
@objc
func
toBack
()
{
@objc
func
toBack
()
{
if
web
v
iew
.
canGoBack
{
if
web
V
iew
.
canGoBack
{
web
v
iew
.
goBack
()
web
V
iew
.
goBack
()
}
}
}
}
@objc
func
toForward
()
{
@objc
func
toForward
()
{
if
webview
.
canGoForward
{
if
webView
.
canGoForward
{
webview
.
goForward
()
webView
.
goForward
()
}
}
// MARK: - KVO
override
func
observeValue
(
forKeyPath
keyPath
:
String
?,
of
object
:
Any
?,
change
:
[
NSKeyValueChangeKey
:
Any
]?,
context
:
UnsafeMutableRawPointer
?)
{
if
keyPath
==
"estimatedProgress"
{
self
.
progBar
.
alpha
=
1.0
progBar
.
setProgress
(
Float
(
webview
.
estimatedProgress
),
animated
:
true
)
//进度条的值最大为1.0
if
(
self
.
webview
.
estimatedProgress
>=
1.0
)
{
UIView
.
animate
(
withDuration
:
0.3
,
delay
:
0.1
,
options
:
.
curveEaseInOut
,
animations
:
{
()
->
Void
in
self
.
progBar
.
alpha
=
0.0
},
completion
:
{
(
finished
:
Bool
)
->
Void
in
self
.
progBar
.
progress
=
0
})
}
}
}
}
}
override
class
func
observeValue
(
forKeyPath
keyPath
:
String
?,
of
object
:
Any
?,
change
:
[
NSKeyValueChangeKey
:
Any
]?,
context
:
UnsafeMutableRawPointer
?)
{
}
}
}
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