【问题标题】:Creating new view controller创建新的视图控制器
【发布时间】:2018-12-08 15:17:27
【问题描述】:

我正在尝试以编程方式创建一个新的视图控制器,而不是在 Xcode 上使用情节提要。我对编码很陌生,不明白我必须在框架所在的括号中加上什么值。代码都在应用程序委托上,请您帮忙。

    let layout = UICollectionViewFlowLayout()

    window = UIWindow(frame: UIScreen.main.bounds)
    window?.makeKeyAndVisible()
    window?.rootViewController = UINavigationController(rootViewController: Homecontroller(frame: -, collectionViewLayout: layout))

【问题讨论】:

    标签: ios swift xcode user-interface uiviewcontroller


    【解决方案1】:

    检查一下

    window = UIWindow(frame: UIScreen.main.bounds)
        window?.makeKeyAndVisible()
        let layout = UICollectionViewFlowLayout()
         window?.rootViewController = UINavigationController(rootViewController: HomeController(collectionViewLayout: layout))
    

    你的 HomeController 应该是这样的

    class HomeController: UICollectionViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
       }
    }
    

    【讨论】:

      猜你喜欢
      • 2015-04-19
      • 1970-01-01
      • 2010-10-30
      • 2014-09-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-05
      • 2014-05-26
      相关资源
      最近更新 更多