@interface ViewController ()<UIWebViewDelegate>
@property (nonatomic,strong) UIWebView *webView;
@property (nonatomic,strong) NSString *str;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0, [UIScreen mainScreen].bounds.size.height - 68, 100, 40);
button.backgroundColor = [UIColor redColor];
[button addTarget:self action:@selector(updataWebView) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
self.str = @"http://www.taobao.com";
self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height - 68)];
[self.view addSubview: self.webView];
self.webView.delegate = self;
[self loadWebView];
// Do any additional setup after loading the view, typically from a nib.
}
//点击按钮重新加载地址
-(void)updataWebView{
self.str = @"http://www.baidu.com";
[self loadWebView];
}
-(void)loadWebView{
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:self.str] cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:1];
[self.webView loadRequest:request];
}
@property (nonatomic,strong) UIWebView *webView;
@property (nonatomic,strong) NSString *str;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0, [UIScreen mainScreen].bounds.size.height - 68, 100, 40);
button.backgroundColor = [UIColor redColor];
[button addTarget:self action:@selector(updataWebView) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
self.str = @"http://www.taobao.com";
self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height - 68)];
[self.view addSubview: self.webView];
self.webView.delegate = self;
[self loadWebView];
// Do any additional setup after loading the view, typically from a nib.
}
//点击按钮重新加载地址
-(void)updataWebView{
self.str = @"http://www.baidu.com";
[self loadWebView];
}
-(void)loadWebView{
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:self.str] cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:1];
[self.webView loadRequest:request];
}