繁体   English   中英

在UIViewController上动态创建UIWebView

[英]creating a UIWebView dynamically on a UIViewController

我需要用UIWebView动态填充UIViewController。 我正在使用UIWebviewController自动在iPhone和iPad上加载。 我正在使用UINavigationController将UIViewController推到屏幕上。

这是我所做的

在视图控制器代码中(在* .h中)

@property (weak, nonatomic) IBOutlet UIWebView *webview;

(在* .m文件中)

@synthesize webview;

(在viewDidLoaded方法中)

self.webview = [[UIWebView alloc] initWithFrame:self.view.bounds];
self.webview.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
self.webview.delegate = self;
[self.view addSubview:self.webview];

我正在像这样推动viewcontroller

CommonViewController *commonController = [CommonViewController alloc] initWithNibName:nil bundle:nil];
[self.navigationController pushViewController:commonController animated:YES];

我正在例外

*由于未捕获的异常'NSInternalInconsistencyException'而终止应用程序,原因:'-[[UIViewController _loadViewFromNibNamed:bundle:]加载了“ CommonViewController”笔尖,但未设置视图出口。 *

谁能告诉我是什么引起了异常。 我已经添加了webview进行查看,我不确定下一步该怎么做!!!

阅读此文章: 已加载笔尖但未设置视图出口-InterfaceBuilder的新功能

您忘记了执行此步骤: You should see "outlets" with "view" under it. Drag the circle next to it over to the "view" icon on the left bar (bottom one, looks like a white square with a thick gray outline You should see "outlets" with "view" under it. Drag the circle next to it over to the "view" icon on the left bar (bottom one, looks like a white square with a thick gray outline

希望这对您有帮助...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM