将 UIWebView 添加到 NavigationViewController
我想将 UIWebView 添加到我的 NavigationViewController 的视图中。这是我正在做的,
在我的 NavigationViewController.h 中:
@interface NavViewController : UINavigationController {
IBOutlet UIWebView *webView;
}
@property (nonatomic, retain) IBOutlet UIWebView *webView;
在实现文件中:
- (void)viewDidLoad {
[super viewDidLoad];
NSString *path = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"html"];
NSURL *url = [NSURL fileURLWithPath:path];
NSURLRequest *req = [NSURLRequest requestWithURL:url];
[webView loadRequest:req];
}
在 IB 中,我将 webView 链接到了插座,资源文件已添加。但是,当我运行该应用程序时,它显示“调试已终止”,然后返回到主页。有什么帮助吗?
好吧,我已经解决了这个问题。谢谢。
I want to add a UIWebView to the view of my NavigationViewController. Here is what I am doing,
In my NavigationViewController.h:
@interface NavViewController : UINavigationController {
IBOutlet UIWebView *webView;
}
@property (nonatomic, retain) IBOutlet UIWebView *webView;
In the implementation file:
- (void)viewDidLoad {
[super viewDidLoad];
NSString *path = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"html"];
NSURL *url = [NSURL fileURLWithPath:path];
NSURLRequest *req = [NSURLRequest requestWithURL:url];
[webView loadRequest:req];
}
And in the IB, I linked the webView to the outlet, the resource file has been added. However, when I run the app, it says "debugging terminated", and return to Home. Any help?
All right, I have fixed this. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您检查过 HTML 文件的名称吗?它的名称是否与 test.html 完全相同?
Have you checked the name of the HTML file. Is it named exactly as test.html??