Xcode 6.3: Could Not Load Nib in Bundle

Could not load NIB in bundle using storyboard

The problem was caused by a SplitViewController with a TabBarController as a MasterViewController.
This cause a crash in iOs 8.3.
I replaced the TabBarController with buttons and now the app is working.

I hope this informations may help someone.

present() method throws 'Could not load NIB in bundle: 'NSBundle

You gave away the biggest hint for what's wrong when you said you are using a storyboard and not a XIB (previously known as a NIB) file.

Try replacing:

let evc = ExerciseViewController(nibName: "ExerciseViewController", bundle: nil)

with

let evc = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("ExerciseViewController") as ExerciseViewController

Here is a tutorial that might help.

iOS - Could not load NIB in bundle

I think the problem may be that you're trying to add the WKWebView to the view when it hasn't been loaded yet.

IBInspectables are set very early in the process of loading the view. Try adding your WKWebView in viewDidLoad or viewWillAppear.

import UIKit
import WebKit

@IBDesignable
class HTMLViewController: UIViewController {
@IBInspectable
var filePath: String! = ""

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if let path = Bundle.main.path(forResource: filePath, ofType: "html", inDirectory: "content") {
do {
let contents = try String(contentsOfFile: path)
let webView = WKWebView(frame: self.view.bounds)
webView.loadHTMLString(contents, baseURL: nil)
self.view.addSubview(webView)
} catch {
print("error loading file")
}
}
}
}


Related Topics



Leave a reply



Submit