现在的位置: 首页 > 综合 > 正文

webview 在自己应用中打开网页

2018年01月08日 ⁄ 综合 ⁄ 共 797字 ⁄ 字号 评论关闭

- (id)init:(NSString*)url{

   
self
= [super
init
];

   
if
(self) {

       
// Custom initialization

       
self
.strurl = url;

    }

   
return self;

}

- (void)viewDidLoad

{

    [super
viewDidLoad];

   
// Do any additional setup after loading the view from its nib.

   
self.mywebview = [[UIWebView
alloc]
initWithFrame:CGRectMake(0, -2,
self.view.bounds.size.width,
self.view.bounds.size.height-44)];

   
self
.mywebview.delegate =
self;

   
self.mywebview.scalesPageToFit =
YES;

   
self.mywebview.autoresizingMask =
UIViewAutoresizingFlexibleLeftMargin |
UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin |
UIViewAutoresizingFlexibleTopMargin;

   
self.mywebview.contentMode =
UIViewContentModeScaleAspectFit;

   
NSURL
* url = [NSURL
URLWithString
: self.strurl];

[self.mywebview
loadRequest:[NSURLRequest
requestWithURL:url]];

    [self.view
addSubview:self.mywebview];

}

【上篇】
【下篇】

抱歉!评论已关闭.