界面生成器中的 WKWebView [英] WKWebView in Interface Builder

查看:23
本文介绍了界面生成器中的 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.

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

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