WKWebView in 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.
这篇关于界面生成器中的 WKWebView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:界面生成器中的 WKWebView


基础教程推荐
- 固定小数的Android Money Input 2022-01-01
- “让"到底是怎么回事?关键字在 Swift 中的作用? 2022-01-01
- :hover 状态不会在 iOS 上结束 2022-01-01
- Android ViewPager:在 ViewPager 中更新屏幕外但缓存的片段 2022-01-01
- 如何使 UINavigationBar 背景透明? 2022-01-01
- LocationClient 与 LocationManager 2022-01-01
- Android文本颜色不会改变颜色 2022-01-01
- 在 iOS 上默认是 char 签名还是 unsigned? 2022-01-01
- 使用 Ryzen 处理器同时运行 WSL2 和 Android Studio 2022-01-01
- 如何使用 YouTube API V3? 2022-01-01