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
20d13a65
Commit
20d13a65
authored
Oct 09, 2025
by
Alex朱枝文
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
资源详情多图片刷新优化
parent
7233a776
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
6 deletions
+48
-6
YHResourceDetailViewController.swift
...y(社区)/Resource(资源)/C/YHResourceDetailViewController.swift
+19
-0
YHResourceDetailDocumentsCell.swift
...ty(社区)/Resource(资源)/V/YHResourceDetailDocumentsCell.swift
+29
-6
No files found.
galaxy/galaxy/Classes/Modules/Community(社区)/Resource(资源)/C/YHResourceDetailViewController.swift
View file @
20d13a65
...
...
@@ -246,6 +246,19 @@ extension YHResourceDetailViewController: UITableViewDataSource, UITableViewDele
cell
.
onImageTapped
=
{
[
weak
self
]
index
in
self
?
.
showImageBrowser
(
at
:
index
)
}
cell
.
onImageHeightChanged
=
{
[
weak
self
]
in
guard
let
self
=
self
else
{
return
}
// NSObject.cancelPreviousPerformRequests(
// withTarget: self,
// selector: #selector(self.performBatchReload),
// object: nil
// )
// self.perform(#selector(self.performBatchReload), with: indexPath, afterDelay: 0.01)
// // 使用 performBatchUpdates 避免动画跳动
UIView
.
performWithoutAnimation
{
self
.
tableView
.
reloadRows
(
at
:
[
indexPath
],
with
:
.
none
)
}
}
return
cell
default
:
...
...
@@ -253,6 +266,12 @@ extension YHResourceDetailViewController: UITableViewDataSource, UITableViewDele
}
}
@objc
private
func
performBatchReload
(
indexPath
:
IndexPath
)
{
UIView
.
performWithoutAnimation
{
self
.
tableView
.
reloadRows
(
at
:
[
indexPath
],
with
:
.
none
)
}
}
func
tableView
(
_
tableView
:
UITableView
,
heightForRowAt
indexPath
:
IndexPath
)
->
CGFloat
{
return
UITableView
.
automaticDimension
}
...
...
galaxy/galaxy/Classes/Modules/Community(社区)/Resource(资源)/V/YHResourceDetailDocumentsCell.swift
View file @
20d13a65
...
...
@@ -53,6 +53,7 @@ class YHResourceDetailDocumentsCell: UITableViewCell {
private
var
images
:
[
String
]
=
[]
var
onImageTapped
:
((
Int
)
->
Void
)?
var
onImageHeightChanged
:
(()
->
Void
)?
override
init
(
style
:
UITableViewCell
.
CellStyle
,
reuseIdentifier
:
String
?)
{
super
.
init
(
style
:
style
,
reuseIdentifier
:
reuseIdentifier
)
...
...
@@ -71,6 +72,10 @@ class YHResourceDetailDocumentsCell: UITableViewCell {
contentView
.
addSubview
(
titleLabel
)
contentView
.
addSubview
(
noDataView
)
contentView
.
addSubview
(
imagesStackView
)
titleLabel
.
setContentCompressionResistancePriority
(
.
required
,
for
:
.
vertical
)
titleLabel
.
setContentHuggingPriority
(
.
required
,
for
:
.
vertical
)
imagesStackView
.
setContentCompressionResistancePriority
(
.
defaultLow
,
for
:
.
vertical
)
imagesStackView
.
setContentHuggingPriority
(
.
defaultLow
,
for
:
.
vertical
)
titleLabel
.
snp
.
makeConstraints
{
make
in
make
.
left
.
equalToSuperview
()
.
offset
(
20
)
...
...
@@ -137,18 +142,36 @@ class YHResourceDetailDocumentsCell: UITableViewCell {
imageView
.
isUserInteractionEnabled
=
true
if
let
url
=
URL
(
string
:
imageUrl
)
{
imageView
.
sd_setImage
(
with
:
url
,
placeholderImage
:
UIImage
(
named
:
"people_head_default"
))
// 设置图片视图的高度
imageView
.
snp
.
makeConstraints
{
make
in
make
.
height
.
equalTo
(
imageHeight
)
}
imageView
.
sd_setImage
(
with
:
url
,
placeholderImage
:
UIImage
(
named
:
"plan_product_default"
))
{
[
weak
self
]
image
,
_
,
_
,
_
in
guard
let
self
=
self
else
{
return
}
guard
let
image
=
image
,
image
.
size
.
width
>
0
,
image
.
size
.
height
>
0
else
{
return
}
let
newImageHeight
=
image
.
size
.
height
/
image
.
size
.
width
*
imageWidth
let
tapGesture
=
UITapGestureRecognizer
(
target
:
self
,
action
:
#selector(
imageTapped(_:)
)
)
imageView
.
addGestureRecognizer
(
tapGesture
)
imageView
.
tag
=
index
// 关键:用 updateConstraints 而不是 remakeConstraints
imageView
.
snp
.
updateConstraints
{
make
in
make
.
height
.
equalTo
(
newImageHeight
)
}
self
.
onImageHeightChanged
?()
}
}
else
{
// 设置图片视图的高度
imageView
.
snp
.
makeConstraints
{
make
in
make
.
height
.
equalTo
(
imageHeight
)
make
.
height
.
equalTo
(
imageWidth
)
}
imageView
.
image
=
UIImage
(
named
:
"plan_product_default"
)
}
let
tapGesture
=
UITapGestureRecognizer
(
target
:
self
,
action
:
#selector(
imageTapped(_:)
)
)
imageView
.
addGestureRecognizer
(
tapGesture
)
imageView
.
tag
=
index
imagesStackView
.
addArrangedSubview
(
imageView
)
}
}
...
...
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