您的位置:首页 > 移动开发

uiwebview加载网页后根据内容设置大小

2014-02-15 15:57 393 查看
-(void)setWebView{

web=[[UIWebView
alloc]initWithFrame:CGRectMake(5, imageView.frame.origin.y+imageView.frame.size.height,
310, 0)];
web.userInteractionEnabled =NO;
NSString* url=self.gamemodel.appIntroduce;
NSURLRequest* re=[[NSURLRequest
alloc]initWithURL:[NSURL
URLWithString:url]];

[web loadRequest:re];
web.autoresizingMask=UIViewAutoresizingFlexibleHeight;
[(UIScrollView* )[[web
subviews]objectAtIndex:0]setBounces:NO];
web.scalesPageToFit =NO;
web.delegate =self;
[ms
addSubview:web];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView{
CGRect frame = webView.frame;
frame.size.height =
1;
webView.frame = frame;
CGSize fittingSize = [webView
sizeThatFits:CGSizeZero];
frame.size = fittingSize;
webView.frame = frame;
// frame 根据实际需求来写
[ms setContentSize:CGSizeMake(320,webView.frame.size.height+self.gamemodel.appTesks.count*51+30+22)];
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: