Anda di halaman 1dari 2

WebView - Failed to set (contentViewController) user defined inspected property on (NSWindow)

I create a new Xcode project from scratch and it compiles fine.

I add a label to the View Controller and this compiles / runs / shows fine.

I then drag in a WebView into the View Controller but get this message when I run the
application:

Failed to set (contentViewController) user defined inspected property on


(NSWindow): *** -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of
class (WebView)

What am I doing wrong?

xcode osx webview

asked Apr 25 '15 at 18:50


Snowcrash
28k 29 91 151

4 Answers

Just Link Webkit.framework in general->Linked Framework and


Libraries

answered Mar 29 '16 at 3:22


user2589681
11 1

Well first of all you need to define the Web view so it actually knows what todo all it is doing
right now is trying to find what to run here, see a tutorial on youtube or such, this is the code i
used for mine, just to set it up. first you want to put the web view into the view controller and
add a toolbar to the bottom of it. add four bar button items onto the bar. and put a fixed space
in-between the two.

then you need to set the styles of them do this by going to attributes inspector> button type >
choose style choose the following for the button 1st one is rewind 2nd is forward 3rd one is
refresh last one is Cancel.

then control click and drag the button to the web view it will give you the options for it like load
rewind and refresh.

then go to your storyboard and make sure you have you main and header files connected do
this by selected the view controller in the storyboard files, then change the class to the view
controller you want to hook up to. then hit enter

go to your header file(.h) and insert the following code,

@property (nonatomic, strong) IBOutlet UIWebView *webView;


put it under the @interface with brackets but make sure that the code is not inside of the
brackets.

then what you need to do is go to your main file(.m) and insert the following code like this

@interface WebViewController ()

@end

@implementation WebViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
//custom initialization
}
return self;
}

- (void)viewDidLoad {

NSURL *url = [NSURL URLWithString:@"https://www.google.com"];


NSURLRequest *requestURL = [NSURLRequest requestWithURL:url]; [_webView
loadRequest:requestURL];
[super viewDidLoad];
// Do any additional setup after loading the view.
}

accept obviously you need to replace the void or just past into the right places Then build and
Run your code use iOS simulator iPhone 6.

Hope this helps have a nice day!

answered Apr 25 '15 at 19:05


Noah Mayo
54 14

judging on the error text this is Mac App, not iOS (there is NSWindow) Eugene Braginets Dec 17 '15 at
11:16

You should be using the wrong property webFrame of WebView instead of


mainFrame

if let url = NSBundle.mainBundle().URLForResource("index", withExtension: "html"){


editorWebView.mainFrame.loadRequest(NSURLRequest(URL: url))
}

answered Sep 6 '15 at 3:21


Roger
483 6 14

I don't think you are doing anything wrong. Its just


a bug

answered Apr 20 '16 at 0:43


real 19
481 5 24

Anda mungkin juga menyukai