【发布时间】:2015-12-04 14:20:51
【问题描述】:
我现在正在尝试让 UIWebView 显示 google.com,但它没有加载:
我只是得到一个空白屏幕
.h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (strong, nonatomic) IBOutlet UIWebView *webView;
@end
.m
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
NSURL *targetURL = [NSURL URLWithString:@"http://www.google.com"];
NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
[_webView loadRequest:request];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
我所做的是创建一个 web 视图:
- 创建了一个新的 UIViewController 场景
- 为其添加了 UIWebView
- 将 webview 连接到 .h 控制器
- 将我的场景设为初始场景
- 运行应用程序,没有加载任何内容,没有错误,直接进入 UIViewController 没有任何内容,请帮助。
我尝试添加以下内容:
[self.view addSubview:self.webView];
什么都没做
【问题讨论】:
-
你试过了吗[webView loadRequest:request]; , 你还必须在你的实现中使用 webview 属性。
-
当插座已经存在时,尝试将其添加为子视图时没有意义
标签: ios objective-c uiwebview