How to create project without story board in xcode

2019-04-14 09:50发布

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

enter image description here

EDIT

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

enter image description here

标签: swift xib xcode6
3条回答
看我几分像从前
2楼-- · 2019-04-14 10:30

I resolve my issue..

See the screen

enter image description here

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

查看更多
劫难
3楼-- · 2019-04-14 10:32

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

查看更多
祖国的老花朵
4楼-- · 2019-04-14 10:40

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.

查看更多
登录 后发表回答