私はスタックオーバーフローとGoogleで同様の問題を見ましたが、私の問題は解決しません。私はMain.storyboardでページスクロールビューを使用するアプリケーションを設計しました。これは他のストーリーボード[ページ]の間を水平にスクロールします。私は助けにJared DavidsonによってビデオSnapchat-Like Menuを使用しました。ページスクロールビュー内のすべてが右に表示されます
前に、私はそれが期待されるように、中心にあった。私はXcode 8にアップデートしたときに変更されたと思います(しかし確かではありません)。しかし、すべてが正しいです。 Xcode 8にアップデートしたときに変わったと思いますが(確かではありません)、フレームを更新しようとしましたが、失敗しました。あなたの問題と私のViewControllerコードを示すのに役立ついくつかの画像が添付されています。
私は何ができますか?
ありがとうございます。
//
// ViewController.swift
//
//
// Created by Lucas Farleigh on 13/08/2016.
//
import UIKit
class ViewController: UIViewController {
@IBOutlet var MyScrollView: UIScrollView!
override func viewDidLoad() {
super.viewDidLoad()
//Declaring the child views
let VM : TitlePageViewController = TitlePageViewController(nibName: "TitlePageViewController", bundle: nil)
let V1 : View1 = View1(nibName: "View1", bundle: nil)
let V2 : View2 = View2(nibName: "View2", bundle: nil)
let V3 : View3 = View3(nibName: "View3", bundle: nil)
let V4 : View4 = View4(nibName: "View4", bundle: nil)
let V5 : View5 = View5(nibName: "View5", bundle: nil)
let V6 : View6 = View6(nibName: "View6", bundle: nil)
let V7 : View7 = View7(nibName: "View7", bundle: nil)
let V8 : View8 = View8(nibName: "View8", bundle: nil)
let V9 : View9 = View9(nibName: "View9", bundle: nil)
let V10 : View10 = View10(nibName: "View10", bundle: nil)
let V11 : View11 = View11(nibName: "View11", bundle: nil)
let V12 : View12 = View12(nibName: "View12", bundle: nil)
let V13 : View13 = View13(nibName: "View13", bundle: nil)
let V14 : View14 = View14(nibName: "View14", bundle: nil)
let V15 : View15 = View15(nibName: "View15", bundle: nil)
let V16 : View16 = View16(nibName: "View16", bundle: nil)
let V17 : View17 = View17(nibName: "View17", bundle: nil)
let V18 : View18 = View18(nibName: "View18", bundle: nil)
let V19 : View19 = View19(nibName: "View19", bundle: nil)
let V20 : View20 = View20(nibName: "View20", bundle: nil)
let V21 : View21 = View21(nibName: "View21", bundle: nil)
let V22 : View22 = View22(nibName: "View22", bundle: nil)
let V23 : View23 = View23(nibName: "View23", bundle: nil)
let V24 : View24 = View24(nibName: "View24", bundle: nil)
let V25 : View25 = View25(nibName: "View25", bundle: nil)
let V26 : View26 = View26(nibName: "View26", bundle: nil)
let V27 : View27 = View27(nibName: "View27", bundle: nil)
let V28 : View28 = View28(nibName: "View28", bundle: nil)
let V29 : View29 = View29(nibName: "View29", bundle: nil)
let V30 : View30 = View30(nibName: "View30", bundle: nil)
let V31 : View31 = View31(nibName: "View31", bundle: nil)
let V32 : View32 = View32(nibName: "View32", bundle: nil)
let V33 : View33 = View33(nibName: "View33", bundle: nil)
let V34 : View34 = View34(nibName: "View34", bundle: nil)
let V35 : View35 = View35(nibName: "View35", bundle: nil)
let V36 : View36 = View36(nibName: "View36", bundle: nil)
let V37 : View37 = View37(nibName: "View37", bundle: nil)
let V38 : View38 = View38(nibName: "View38", bundle: nil)
let V39 : View39 = View39(nibName: "View39", bundle: nil)
let V40 : View40 = View40(nibName: "View40", bundle: nil)
let V41 : View39 = View39(nibName: "View41", bundle: nil)
let V42 : View40 = View40(nibName: "View42", bundle: nil)
//Decraling that the child views are child views
self.addChildViewController(VM)
self.addChildViewController(V1)
self.addChildViewController(V2)
self.addChildViewController(V3)
self.addChildViewController(V4)
self.addChildViewController(V5)
self.addChildViewController(V6)
self.addChildViewController(V7)
self.addChildViewController(V8)
self.addChildViewController(V9)
self.addChildViewController(V10)
self.addChildViewController(V11)
self.addChildViewController(V12)
self.addChildViewController(V13)
self.addChildViewController(V14)
self.addChildViewController(V15)
self.addChildViewController(V16)
self.addChildViewController(V17)
self.addChildViewController(V18)
self.addChildViewController(V19)
self.addChildViewController(V20)
self.addChildViewController(V21)
self.addChildViewController(V22)
self.addChildViewController(V23)
self.addChildViewController(V24)
self.addChildViewController(V25)
self.addChildViewController(V26)
self.addChildViewController(V27)
self.addChildViewController(V28)
self.addChildViewController(V29)
self.addChildViewController(V30)
self.addChildViewController(V31)
self.addChildViewController(V32)
self.addChildViewController(V33)
self.addChildViewController(V34)
self.addChildViewController(V35)
self.addChildViewController(V36)
self.addChildViewController(V37)
self.addChildViewController(V38)
self.addChildViewController(V39)
self.addChildViewController(V40)
self.addChildViewController(V41)
self.addChildViewController(V42)
//Adding the view into the scrollview (MyScrollView)
/**/ self.MyScrollView.addSubview(VM.view)
self.MyScrollView.addSubview(V1.view)
self.MyScrollView.addSubview(V2.view)
self.MyScrollView.addSubview(V3.view)
self.MyScrollView.addSubview(V4.view)
self.MyScrollView.addSubview(V5.view)
self.MyScrollView.addSubview(V6.view)
self.MyScrollView.addSubview(V7.view)
self.MyScrollView.addSubview(V8.view)
self.MyScrollView.addSubview(V9.view)
self.MyScrollView.addSubview(V10.view)
self.MyScrollView.addSubview(V11.view)
self.MyScrollView.addSubview(V12.view)
self.MyScrollView.addSubview(V13.view)
self.MyScrollView.addSubview(V14.view)
self.MyScrollView.addSubview(V15.view)
self.MyScrollView.addSubview(V16.view)
self.MyScrollView.addSubview(V17.view)
self.MyScrollView.addSubview(V18.view)
self.MyScrollView.addSubview(V19.view)
self.MyScrollView.addSubview(V20.view)
self.MyScrollView.addSubview(V21.view)
self.MyScrollView.addSubview(V22.view)
self.MyScrollView.addSubview(V23.view)
self.MyScrollView.addSubview(V24.view)
self.MyScrollView.addSubview(V25.view)
self.MyScrollView.addSubview(V26.view)
self.MyScrollView.addSubview(V27.view)
self.MyScrollView.addSubview(V28.view)
self.MyScrollView.addSubview(V29.view)
self.MyScrollView.addSubview(V30.view)
self.MyScrollView.addSubview(V31.view)
self.MyScrollView.addSubview(V32.view)
self.MyScrollView.addSubview(V33.view)
self.MyScrollView.addSubview(V34.view)
self.MyScrollView.addSubview(V35.view)
self.MyScrollView.addSubview(V36.view)
self.MyScrollView.addSubview(V37.view)
self.MyScrollView.addSubview(V38.view)
self.MyScrollView.addSubview(V39.view)
self.MyScrollView.addSubview(V40.view)
self.MyScrollView.addSubview(V41.view)
self.MyScrollView.addSubview(V42.view)
//Confirming that it did move to the view controller
/**/ VM.didMove(toParentViewController: self)
V1.didMove(toParentViewController: self)
V2.didMove(toParentViewController: self)
V3.didMove(toParentViewController: self)
V4.didMove(toParentViewController: self)
V5.didMove(toParentViewController: self)
V6.didMove(toParentViewController: self)
V7.didMove(toParentViewController: self)
V8.didMove(toParentViewController: self)
V9.didMove(toParentViewController: self)
V10.didMove(toParentViewController: self)
V11.didMove(toParentViewController: self)
V12.didMove(toParentViewController: self)
V13.didMove(toParentViewController: self)
V14.didMove(toParentViewController: self)
V15.didMove(toParentViewController: self)
V16.didMove(toParentViewController: self)
V17.didMove(toParentViewController: self)
V18.didMove(toParentViewController: self)
V19.didMove(toParentViewController: self)
V20.didMove(toParentViewController: self)
V21.didMove(toParentViewController: self)
V22.didMove(toParentViewController: self)
V23.didMove(toParentViewController: self)
V24.didMove(toParentViewController: self)
V25.didMove(toParentViewController: self)
V26.didMove(toParentViewController: self)
V27.didMove(toParentViewController: self)
V28.didMove(toParentViewController: self)
V29.didMove(toParentViewController: self)
V30.didMove(toParentViewController: self)
V31.didMove(toParentViewController: self)
V32.didMove(toParentViewController: self)
V33.didMove(toParentViewController: self)
V34.didMove(toParentViewController: self)
V35.didMove(toParentViewController: self)
V36.didMove(toParentViewController: self)
V37.didMove(toParentViewController: self)
V38.didMove(toParentViewController: self)
V39.didMove(toParentViewController: self)
V40.didMove(toParentViewController: self)
V41.didMove(toParentViewController: self)
V42.didMove(toParentViewController: self)
//SIZES AND POSITIONS
//Declaring how big the scroll view is
self.MyScrollView.contentSize = CGSize(width: self.view.frame.width * 43, height: self.view.frame.height)
//Setting the frame of the Views
var V1Frame : CGRect = V1.view.frame
var V2Frame : CGRect = V2.view.frame
var V3Frame : CGRect = V3.view.frame
var V4Frame : CGRect = V4.view.frame
var V5Frame : CGRect = V5.view.frame
var V6Frame : CGRect = V6.view.frame
var V7Frame : CGRect = V7.view.frame
var V8Frame : CGRect = V8.view.frame
var V9Frame : CGRect = V9.view.frame
var V10Frame : CGRect = V10.view.frame
var V11Frame : CGRect = V11.view.frame
var V12Frame : CGRect = V12.view.frame
var V13Frame : CGRect = V13.view.frame
var V14Frame : CGRect = V14.view.frame
var V15Frame : CGRect = V15.view.frame
var V16Frame : CGRect = V16.view.frame
var V17Frame : CGRect = V17.view.frame
var V18Frame : CGRect = V18.view.frame
var V19Frame : CGRect = V19.view.frame
var V20Frame : CGRect = V20.view.frame
var V21Frame : CGRect = V21.view.frame
var V22Frame : CGRect = V22.view.frame
var V23Frame : CGRect = V23.view.frame
var V24Frame : CGRect = V24.view.frame
var V25Frame : CGRect = V25.view.frame
var V26Frame : CGRect = V26.view.frame
var V27Frame : CGRect = V27.view.frame
var V28Frame : CGRect = V28.view.frame
var V29Frame : CGRect = V29.view.frame
var V30Frame : CGRect = V30.view.frame
var V31Frame : CGRect = V31.view.frame
var V32Frame : CGRect = V32.view.frame
var V33Frame : CGRect = V33.view.frame
var V34Frame : CGRect = V34.view.frame
var V35Frame : CGRect = V35.view.frame
var V36Frame : CGRect = V36.view.frame
var V37Frame : CGRect = V37.view.frame
var V38Frame : CGRect = V38.view.frame
var V39Frame : CGRect = V39.view.frame
var V40Frame : CGRect = V40.view.frame
var V41Frame : CGRect = V41.view.frame
var V42Frame : CGRect = V42.view.frame
//Making it off the screen to the right
V1Frame.origin.x = self.view.frame.width
V2Frame.origin.x = 2 * self.view.frame.width
V3Frame.origin.x = 3 * self.view.frame.width
V4Frame.origin.x = 4 * self.view.frame.width
V5Frame.origin.x = 5 * self.view.frame.width
V6Frame.origin.x = 6 * self.view.frame.width
V7Frame.origin.x = 7 * self.view.frame.width
V8Frame.origin.x = 8 * self.view.frame.width
V9Frame.origin.x = 9 * self.view.frame.width
V10Frame.origin.x = 10 * self.view.frame.width
V11Frame.origin.x = 11 * self.view.frame.width
V12Frame.origin.x = 12 * self.view.frame.width
V13Frame.origin.x = 13 * self.view.frame.width
V14Frame.origin.x = 14 * self.view.frame.width
V15Frame.origin.x = 15 * self.view.frame.width
V16Frame.origin.x = 16 * self.view.frame.width
V17Frame.origin.x = 17 * self.view.frame.width
V18Frame.origin.x = 18 * self.view.frame.width
V19Frame.origin.x = 19 * self.view.frame.width
V20Frame.origin.x = 20 * self.view.frame.width
V21Frame.origin.x = 21 * self.view.frame.width
V22Frame.origin.x = 22 * self.view.frame.width
V23Frame.origin.x = 23 * self.view.frame.width
V24Frame.origin.x = 24 * self.view.frame.width
V25Frame.origin.x = 25 * self.view.frame.width
V26Frame.origin.x = 26 * self.view.frame.width
V27Frame.origin.x = 27 * self.view.frame.width
V28Frame.origin.x = 28 * self.view.frame.width
V29Frame.origin.x = 29 * self.view.frame.width
V30Frame.origin.x = 30 * self.view.frame.width
V31Frame.origin.x = 31 * self.view.frame.width
V32Frame.origin.x = 32 * self.view.frame.width
V33Frame.origin.x = 33 * self.view.frame.width
V34Frame.origin.x = 34 * self.view.frame.width
V35Frame.origin.x = 35 * self.view.frame.width
V36Frame.origin.x = 36 * self.view.frame.width
V37Frame.origin.x = 37 * self.view.frame.width
V38Frame.origin.x = 38 * self.view.frame.width
V39Frame.origin.x = 39 * self.view.frame.width
V40Frame.origin.x = 40 * self.view.frame.width
V41Frame.origin.x = 41 * self.view.frame.width
V42Frame.origin.x = 42 * self.view.frame.width
//Adding it on to the view
V1.view.frame = V1Frame
V2.view.frame = V2Frame
V3.view.frame = V3Frame
V4.view.frame = V4Frame
V5.view.frame = V5Frame
V6.view.frame = V6Frame
V7.view.frame = V7Frame
V8.view.frame = V8Frame
V9.view.frame = V9Frame
V10.view.frame = V10Frame
V11.view.frame = V11Frame
V12.view.frame = V12Frame
V13.view.frame = V13Frame
V14.view.frame = V14Frame
V15.view.frame = V15Frame
V16.view.frame = V16Frame
V17.view.frame = V17Frame
V18.view.frame = V18Frame
V19.view.frame = V19Frame
V20.view.frame = V20Frame
V21.view.frame = V21Frame
V22.view.frame = V22Frame
V23.view.frame = V23Frame
V24.view.frame = V24Frame
V25.view.frame = V25Frame
V26.view.frame = V26Frame
V27.view.frame = V27Frame
V28.view.frame = V28Frame
V29.view.frame = V29Frame
V30.view.frame = V30Frame
V31.view.frame = V31Frame
V32.view.frame = V32Frame
V33.view.frame = V33Frame
V34.view.frame = V34Frame
V35.view.frame = V35Frame
V36.view.frame = V36Frame
V37.view.frame = V37Frame
V38.view.frame = V38Frame
V39.view.frame = V39Frame
V40.view.frame = V40Frame
V41.view.frame = V41Frame
V42.view.frame = V42Frame
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
AutoLayoutを使用していますか?それは私の最初の推測だろう。残念ながら、コードを見ることなく、診断することは非常に困難です。 – brandonscript
コードを追加します –
"Swift Xcode 8"をタイトルに追加する必要はありません。すでにこれらのタグが含まれています。 –