Interface Builder中的WKWebView [英] WKWebView in Interface Builder

查看:99
本文介绍了Interface Builder中的WKWebView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎XCode 6 beta中的IB对象模板仍在创建旧式对象(iOS的UIWebView和OSX的WebView)。希望Apple会为现代WebKit更新它们,但在那之前,在Interface Builder中创建WKWebViews的最佳方法是什么?我应该创建一个基本视图(UIView或NSView)并将其类型分配给WKWebView吗?我在网上找到的大多数例子都是以编程方式将它添加到容器视图中;是因为某种原因更好吗?

It seems that the IB object templates in XCode 6 beta are still creating old-style objects (UIWebView for iOS and WebView for OSX). Hopefully Apple will update them for the modern WebKit, but until then, what is the best way to create WKWebViews in Interface Builder? Should I create a basic view (UIView or NSView) and assign its type to WKWebView? Most of the examples I find online add it to a container view programmatically; is that better for some reason?

推荐答案

你是对的 - 它似乎不起作用。如果你查看标题,你会看到:

You are correct - it doesn't seem to work. If you look in the headers, you'll see:

- (instancetype)initWithCoder:(NSCoder *)coder NS_UNAVAILABLE;

这意味着您无法从笔尖实例化一个。

which implies that you can't instantiate one from a nib.

你必须在viewDidLoad或loadView中手动完成。

You'll have to do it by hand in viewDidLoad or loadView.

这篇关于Interface Builder中的WKWebView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆