How to create project without story board in xcode 6 (swift)?

萝らか妹 提交于 2019-12-06 09:43:16

问题


Can any one has practiced creating project in xcode6 (swift) without storyboard.

I am able to implement

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
    // Override point for customization after application launch.

    self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
    self.window!.backgroundColor = UIColor.whiteColor()
    self.window!.makeKeyAndVisible()

    var viewController: ViewController? = ViewController(nibName: "ViewController", bundle: nil)
    self.navigationController = UINavigationController(rootViewController: viewController)
    self.window!.rootViewController = self.navigationController

    return true
}

but it fails with following error

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 
'-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "ViewController" nib but the 
view outlet was not set.'

so i tried to relate file's owner UIView with xib, but i am unable to see UIView in file's owner property.

See the screen below

EDIT

Thanks Alex but from the second last point from HERE i am unable to find any view. See the screen attached


回答1:


I resolve my issue..

See the screen

Something strange with xcode6 beta, i am not sure whats wrong with it.




回答2:


In Xcode 6 , you will get two custom class field in file inspector.you should enter your view controller name in second custom class field. when you enter the name then you can see view outlet under file owner properties.




回答3:


Please ensure you have connected correctly your class with nib file. Especially, File's Owner setting. The same steps sequence for Swift as for Obj-C.

Try to reload XCode and re-save .nib file

See the instructions from here: https://stackoverflow.com/a/6395750/2429147

or here: https://stackoverflow.com/a/17321200/2429147



来源:https://stackoverflow.com/questions/24677258/how-to-create-project-without-story-board-in-xcode-6-swift

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!