我试图在UIScollView中动态添加按钮,以便当按钮溢出而不是其大小但没有发生时,它可以滚动。
for data in result as! [NSManagedObject] {
let magButton=UIButton(frame: CGRect(x: Int(newScroll.frame.origin.x), y: verti, width: Int(newScroll.frame.width), height: 25))
magButton.addTarget(self, action: #selector(imageTapped), for: UIControlEvents.touchUpInside)
magButton.backgroundColor=UIColor.gray
magButton.tag=count
magButton.contentMode = .left
magButton.setTitle(data.value(forKey: "name") as! String, for: UIControlState.normal)
myScrollVew.addSubview(magButton)
verti+=26
}
答案 0 :(得分:1)
添加最后一行以更新滚动视图内容大小。
UnityWebRequest