ViewController看起来不正常

时间:2017-05-31 09:47:16

标签: ios swift xcode

我有一个看起来像这样的ViewController:

enter image description here

但是当我运行它时,它看起来像这样:

enter image description here

看看ViewController中的一些代码:

    @IBAction func derecourtButton(_ sender: Any) {

        self.performSegue(withIdentifier: "classtoperiod", sender: self)

    }


    @IBAction func myburghButton(_ sender: Any) {

        self.performSegue(withIdentifier: "classtoperiod", sender: self)

    }


    @IBAction func edmondsonButton(_ sender: Any) {

        self.performSegue(withIdentifier: "classtoperiod", sender: self)

    }


    @IBAction func healyButton(_ sender: Any) {

        self.performSegue(withIdentifier: "classtoperiod", sender: self)

    }


    @IBAction func bormansButton(_ sender: Any) {

        self.performSegue(withIdentifier: "classtoperiod", sender: self)

    }


    @IBAction func jackwaysButton(_ sender: Any) {

        self.performSegue(withIdentifier: "classtoperiod", sender: self)

    }

    @IBAction func horrackButton(_ sender: Any) {

        self.performSegue(withIdentifier: "classtoperiod", sender: self)

    }


    @IBAction func mchughButton(_ sender: Any) {

        self.performSegue(withIdentifier: "classtoperiod", sender: self)

    }


    @IBAction func youngButton(_ sender: Any) {

        self.performSegue(withIdentifier: "classtoperiod", sender: self)

    }


    @IBAction func mitchellButton(_ sender: Any) {

        self.performSegue(withIdentifier: "classtoperiod", sender: self)

    }


    @IBAction func testerButton(_ sender: Any) {

        self.performSegue(withIdentifier: "classtoperiod", sender: self)

    }


    @IBAction func parrButton(_ sender: Any) {

        self.performSegue(withIdentifier: "classtoperiod", sender: self)

    }


    @IBAction func holdenButton(_ sender: Any) {

        self.performSegue(withIdentifier: "classtoperiod", sender: self)

    }

怎么了?

1 个答案:

答案 0 :(得分:0)

问题不在代码中,而是在.xib文件中。您实施的所有视图都没有足够的空间。您必须构建所有视图设置约束。因此,您可以说某些东西具有容器或其他元素的高度百分比和宽度百分比。或者使用%尺寸或px将它们设置在中间或任何您想要的位置。

您需要的是autolayout& amp;约束

Here你有2个Raywenderlich教程。

我在这里看到你有一个滚动视图,你有一个关于如何使用scrollview的教程!

但是,首先你需要learn about constraints,它们太重要了。