首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >第二个vc比初始vc小

第二个vc比初始vc小
EN

Stack Overflow用户
提问于 2019-10-04 18:56:08
回答 1查看 39关注 0票数 0

昨天更新后,我在iPad上遇到了这个问题:如果我加载第二个视图控制器,它看起来比最初的要小(见下图)。有趣的是,只有在我更新了iPad上的新iOS之后,这种情况才会发生。在iPhone上没有这样的问题:两家风投的规模都是一样的。

代码如下:

代码语言:javascript
复制
import UIKit

class StartVC: UIViewController, ButtonDelegate {


   var width = CGFloat()
   var height = CGFloat()




override func viewDidLoad() {
    super.viewDidLoad()

    width = view.frame.width
    height = view.frame.height

    setTestBtn()


    view.backgroundColor = UIColor.purple

}

func setTestBtn(){

    let a = Button(frame: CGRect(x: 0,y: 0, width: width*0.2, height: width*0.2))
    a.center = CGPoint(x: width*0.5, y: height*0.5)
    a.backgroundColor = .cyan
    a.delegate = self
    a.setLabel()
    a.label.text = "Go to the MainVC"
    view.addSubview(a)
}

func buttonClicked(sender: Button) {

    let vc = self.storyboard?.instantiateViewController(withIdentifier: "mainVC") as! MainVC
    let transition = CATransition()
    transition.duration = 2
    transition.type = CATransitionType.push
    transition.subtype = CATransitionSubtype.fromRight
    view.window!.layer.add(transition, forKey: kCATransition)

    vc.view.frame = view.bounds

    self.present(vc, animated: true, completion: nil)


       print("# ViewController func buttonClicked() OK!")

   }




import UIKit

class MainVC: UIViewController, ButtonDelegate {

var width = CGFloat()
var height = CGFloat()

override func viewDidLoad() {
    super.viewDidLoad()

    width = view.frame.width
    height = view.frame.height

    setTestBtn()

    view.backgroundColor = .red


}

func setTestBtn(){

    let a = Button(frame: CGRect(x: 0,y: 0, width: width*0.2, height: width*0.2))
    a.center = CGPoint(x: width*0.5, y: height*0.5)
    a.backgroundColor = .orange
    a.delegate = self
    a.setLabel()
    a.label.text = "Go to the StartVC"
    view.addSubview(a)
}

func buttonClicked(sender: Button) {

    let vc = self.storyboard?.instantiateViewController(withIdentifier: "startVC") as! StartVC
    let transition = CATransition()
    transition.duration = 2
    transition.type = CATransitionType.push
    transition.subtype = CATransitionSubtype.fromRight
    view.window!.layer.add(transition, forKey: kCATransition)

    vc.view.frame = view.bounds

    self.present(vc, animated: true, completion: nil)

       print("# ViewController func buttonClicked() OK!")

   }


}

EN

Stack Overflow用户

回答已采纳

发布于 2019-10-04 19:28:41

自iOS 13发布以来,默认情况下,视图控制器的模式呈现样式由系统自动选择。

如果您希望消除这种影响,这可以帮助您。

代码语言:javascript
复制
vc.modalPresentationStyle = .overFullScreen
self.present(vc, animated: true, completion: nil)

希望这能有所帮助!

票数 0
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58235033

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档