You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Here is a UIViewController, mainly UIScrollView wrapped UIStackView, please note that he is the dynamic height;
if you directly display this "StackViewController" is no problem,
but because of business needs, in order to perform the jump then you need to use "UINavigationController.initWithRoot:StackViewController" , at this time can only display a fixed 44 height of the pop-up window, , look forward to fixing!
Expected behavior
display a UINavigationController with a DynamicHeightViewController
Screenshots
If applicable, add screenshots to help explain your problem.
iPhone (please complete the following information):
Device: iPhone13 Pro Max
iOS Version: iOS 17.4.1
Xcode Version 15
Dependency Manager Version [e.g. CocoaPods 1.5.2, Carthage 0.29.0]
SwiftEntryKit Release # [e.g. 0.2.0]
Additional context
import UIKit
import SnapKit
class StackViewController: UIViewController {
let scrollView = UIScrollView()
let stackView = UIStackView()
let toggleButton = UIButton()
var isHidden = false
override func viewDidLoad() {
super.viewDidLoad()
// 配置 scrollView
scrollView.backgroundColor = .yellow
view.addSubview(scrollView)
scrollView.snp.makeConstraints { make in
make.edges.equalTo(view.safeAreaLayoutGuide)
}
// 配置 stackView
stackView.axis = .vertical
stackView.distribution = .fill
stackView.spacing = 0
scrollView.addSubview(stackView)
stackView.snp.makeConstraints { make in
make.edges.equalToSuperview()
make.width.equalToSuperview()
}
// 获取屏幕高度
let screenHeight = UIScreen.main.bounds.height
// 添加子视图到 stackView
for i in 1...16 {
let subview = UILabel()
subview.text = "\(i)"
subview.tag = i // 为每个子视图设置 tag 以便识别
subview.backgroundColor = i % 2 == 0 ? .red : .blue // 交替颜色便于区分
stackView.addArrangedSubview(subview)
// 设置高度约束
subview.snp.makeConstraints { make in
make.height.equalTo(screenHeight / 10).priority(.required)
}
}
// 配置按钮
toggleButton.setTitle("Toggle Odd Rows", for: .normal)
toggleButton.backgroundColor = .systemBlue
toggleButton.addTarget(self, action: #selector(toggleOddRows), for: .touchUpInside)
view.addSubview(toggleButton)
toggleButton.snp.makeConstraints { make in
make.bottom.equalTo(view.safeAreaLayoutGuide).offset(-20)
make.centerX.equalToSuperview()
make.width.equalTo(200)
make.height.equalTo(50)
}
}
@objc func toggleOddRows() {
isHidden.toggle()
UIView.animate(withDuration: 0.5, animations: {
for i in 1...16 {
if let subview = self.stackView.viewWithTag(i) {
if i % 2 != 0 { // 单数行
subview.isHidden = self.isHidden
}
}
}
self.stackView.layoutIfNeeded() // 强制刷新 stackView 布局
}) { _ in
// 更新 scrollView 内容高度
self.scrollView.setNeedsLayout()
self.scrollView.layoutIfNeeded()
}
}
Describe the bug
Here is a UIViewController, mainly UIScrollView wrapped UIStackView, please note that he is the dynamic height;
if you directly display this "StackViewController" is no problem,
but because of business needs, in order to perform the jump then you need to use "UINavigationController.initWithRoot:StackViewController" , at this time can only display a fixed 44 height of the pop-up window, , look forward to fixing!
Expected behavior
display a UINavigationController with a DynamicHeightViewController
Screenshots
If applicable, add screenshots to help explain your problem.
iPhone (please complete the following information):
Additional context
import UIKit
import SnapKit
class StackViewController: UIViewController {
}
===============
Screenshots / Video Links
![image](https://private-user-images.githubusercontent.com/13254245/343709809-eee8def9-63f0-4dbe-b11e-a905e62c02ca.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU3NjM2MjUsIm5iZiI6MTcyNTc2MzMyNSwicGF0aCI6Ii8xMzI1NDI0NS8zNDM3MDk4MDktZWVlOGRlZjktNjNmMC00ZGJlLWIxMWUtYTkwNWU2MmMwMmNhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTA4VDAyNDIwNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTBjMTQwMTM2ODBiYTQ2MTJmZDkzYmYwNDk3OGU5ZjJiNmM2MzU0NTU1N2Q4MTg2ZWYwNGYxMDI4ZGZiYTA2YWMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.I-FSr2qAKOR_JpqteiCGjuhbt_q19iItEPfP_GeNyl4)
The text was updated successfully, but these errors were encountered: