导读
有两种打开网址的方法,一种是应用内加载,一种是应用外加载
1.应用外打开
[Objective-C] 纯文本查看 复制代码 UIButton *btnOuter = [MTools createButtonWithTitle:@"应用外打开" Font:kFont(14) TitleColor:kColor(orangeColor)];
btnOuter.frame = CGRectMake(100, btnInner.frameBottom + 20, 150, 50);
[btnOuter addButtonClickBlock:^(UIButton *btn) {
openUrl(@"http://www.sufeinet.com");
}];
[self.view addSubview:btnOuter];
2.应用内打开
[Objective-C] 纯文本查看 复制代码 UIButton *btnInner = [MTools createButtonWithTitle:@"应用内打开" Font:kFont(14) TitleColor:kColor(orangeColor)];
btnInner.frame = CGRectMake(100, 80, 150, 50);
[btnInner addButtonClickBlock:^(UIButton *btn) {
PublicWebVC *web = [PublicWebVC new];
web.title = @"苏飞论坛";
pushToViewController(self, web, YES);
}];
[self.view addSubview:btnInner];
新建一个页面继承于BaseWebViewController
[Objective-C] 纯文本查看 复制代码 #import "PublicWebVC.h"
@interface PublicWebVC ()
@end
@implementation PublicWebVC
- (void)viewDidLoad {
[super viewDidLoad];
self.showHud = YES;
[self.theWebView loadRequest:[NSURLRequest requestWithURL:kURL(@"http://www.sufeinet.com")]];
}
看一下效果
附件:
打开网址.zip
(694.98 KB, 下载次数: 0)
|