【问题标题】:creating a UIWebView dynamically on a UIViewController在 UIViewController 上动态创建 UIWebView
【发布时间】:2013-06-07 15:47:48
【问题描述】:

我需要用 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];

我是这样推视图控制器的

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

我遇到了异常

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

谁能告诉我是什么导致了异常。我已经添加了要查看的 webview,我不知道下一步该怎么做!!!

【问题讨论】:

    标签: ios cocoa-touch uiwebview uinavigationcontroller


    【解决方案1】:

    阅读这篇文章:Loaded nib but the view outlet was not set - new to 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

    希望对你有帮助...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-01-11
      • 2015-04-16
      • 1970-01-01
      • 2014-02-01
      • 2014-06-07
      • 2018-03-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多