How to create project without story board in xcode

2019-04-14 10:18发布

问题:

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



标签: swift xib xcode6