-1
我已將視圖控制器的視圖放置在滾動視圖中。但是當我在iPhone 6Plus上運行我的應用程序時,我的視圖沒有填滿屏幕,我可以看到右側的其他視圖。我該如何解決這個問題。調整滾動視圖內的視圖
這裏的問題是
截圖,這是我的代碼
contentView.contentSize = CGSize(width: contentView.frame.size.width * 5, height: contentView.frame.size.height)
rifleViewController.view.frame = contentView.bounds
contentView.addSubview(rifleViewController.view)
pistolViewController.view.frame = contentView.bounds
pistolViewController.view.frame.origin.x = contentView.frame.size.width
contentView.addSubview(pistolViewController.view)
shotgunViewController.view.frame = contentView.bounds
shotgunViewController.view.frame.origin.x = contentView.frame.size.width * 2
contentView.addSubview(shotgunViewController.view)
smgsViewController.view.frame = contentView.bounds
smgsViewController.view.frame.origin.x = contentView.frame.size.width * 3
contentView.addSubview(smgsViewController.view)
sniperViewController.view.frame = contentView.bounds
sniperViewController.view.frame.origin.x = contentView.frame.size.width * 4
contentView.addSubview(sniperViewController.view)
爲什麼不使用'UICollectionView'?將UIViewControllers添加爲子視圖控制器?它提供了完全相同的功能。 – Rikh
你在哪裏設置'scrollView'的contentSize? – Adeel