저는 무료 솔루션의 신속한 버전을 찾고자했습니다. 내 뷰 컨트롤러 스크롤 콘텐츠를 어떻게 만들 수 있는지 궁금합니다. 지금은 단지 정적이며 스크롤 할 수없는 내용이 아래에 있습니다.UIViewController 내용을 스크롤하는 방법은 무엇입니까?
class ProfileViewController: UIViewController, UICollectionViewDelegateFlowLayout {
let postsId = "postsId"
override func viewDidLoad() {
super.viewDidLoad()
view.addSubview(profileContainerView)
view.addSubview(profileTabCollection)
view.addSubview(containerForCollectionView)
view.addSubview(scrollView)
scrollView.widthAnchor.constraintEqualToConstant(view.frame.size.width).active = true
scrollView.heightAnchor.constraintEqualToConstant(view.frame.size.height).active = true
scrollView.centerXAnchor.constraintEqualToAnchor(view.centerXAnchor).active = true
scrollView.centerYAnchor.constraintEqualToAnchor(view.centerYAnchor).active = true
scrollView.userInteractionEnabled = true
scrollView.scrollEnabled = true
scrollView.delegate = self
containerForCollectionView.widthAnchor.constraintEqualToConstant(scrollView.frame.size.width).active = true
containerForCollectionView.heightAnchor.constraintEqualToConstant(scrollView.frame.size.height).active = true
containerForCollectionView.topAnchor.constraintEqualToAnchor(profileTabCollection.bottomAnchor).active = true
profileContainerView.widthAnchor.constraintEqualToConstant(scrollView.frame.size.width).active = true
profileContainerView.heightAnchor.constraintEqualToConstant(250).active = true
profileContainerView.centerXAnchor.constraintEqualToAnchor(scrollView.centerXAnchor).active = true
profileContainerView.topAnchor.constraintEqualToAnchor(topLayoutGuide.bottomAnchor).active = true
profileTabCollection.widthAnchor.constraintEqualToAnchor(profileContainerView.widthAnchor).active = true
profileTabCollection.heightAnchor.constraintEqualToConstant(50).active = true
profileTabCollection.centerXAnchor.constraintEqualToAnchor(view.centerXAnchor).active = true
profileTabCollection.topAnchor.constraintEqualToAnchor(profileContainerView.bottomAnchor).active = true
}
lazy var scrollView: UIScrollView = {
let sv = UIScrollView(frame: CGRectMake(0,0,1024,768))
sv.contentSize = CGSizeMake(self.view.frame.size.width, self.view.frame.size.height * 3)
sv.translatesAutoresizingMaskIntoConstraints = false
return sv
}()
let containerForCollectionView: UIView = {
let view = UIView()
view.backgroundColor = UIColor.purpleColor()
view.translatesAutoresizingMaskIntoConstraints = false
return view
}()
cal이 scrollView.heightAnchor 이후에'scrollView.contentSize = CGSizeMake (view.frame.size.width, view.frame.size.height + 500)' –
흠, 그것 스크롤하지 않는 것 같습니다 –
스토리 보드를 사용하고 있습니까? 그것은 제약에 문제가있는 것처럼 보입니다. –