gpt4 book ai didi

ios - 使 UIView 填充 UIScrollview

转载 作者:行者123 更新时间:2023-11-29 12:00:17 24 4
gpt4 key购买 nike

我有一个带有两个 View 的分页 ScrollView ,第一个用于填充 UIScrollview,第二个位于中间。我不知道出了什么问题,但它不会在 iPhone6 上填充,但它适合 iPhone5。下面是我的代码:

查看层次结构

 UIView
--StackView (Properties -- Axis(Vertical) Alignment(Fill) Distribution(Fill) Spacing(0))
--UIView (Fixed height. 60)
--UIView (Main Views Holder)
--ScrollView(Content Size: Screen Width * 2, Height: Height left between it margin to the MainView and BottomView) and I notice, that the scrollview keeps remaining size 433 on both iPhone5 and 6. And when I check my storyboard, that's the exact same height there
--UIView(Height: 102, Width: Screen Width)BottomView

 @IBOutlet weak var scrollView: UIScrollView!

var rectanglePhot: UIView!
var squarePhoto: UIView!

override func viewDidLoad() {
super.viewDidLoad()

scrollView.contentSize = CGSize(width: self.view.frame.size.width * 2, height: scrollView.frame.size.height)
scrollView.autoresizingMask = .FlexibleWidth
scrollView.translatesAutoresizingMaskIntoConstraints = false
scrollView.backgroundColor = UIColor.greenColor()

iniiCameraView()
}

func iniiCameraView() {
rectanglePhot = UIView(frame: CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: self.scrollView.frame.size.height)) <-- This is the problematic one
//rectanglePhot = UIView()
let specifyY = self.scrollView.frame.size.height - self.view.frame.size.width
squarePhoto = UIView(frame: CGRect(x: self.view.frame.size.width, y: specifyY, width: self.view.frame.size.width, height: self.view.frame.size.width))
scrollView.addSubview(rectanglePhot)
scrollView.addSubview(squarePhoto)

rectanglePhot.backgroundColor = UIColor.blueColor()
squarePhoto.backgroundColor = UIColor.brownColor()

print("Rect Height ", rectanglePhot.frame.size.height)
print("Scroll Height ", scrollView.frame.size.height)
print("Specify Y ", specifyY)
}

和图像Image Added to Scrollview a index[0]

最佳答案

在viewdidappear中添加代码。自动布局将在 viewdidload 之后应用

关于ios - 使 UIView 填充 UIScrollview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37297044/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com