IOS xib webview設置高度

1 初始化

	self.webView.delegate  = self;
	_webView.scrollView.bounces = NO;
	_webView.scrollView.showsHorizontalScrollIndicator = NO;
	_webView.scrollView.scrollEnabled = NO;
	[_webView sizeToFit];

2 獲取webview的高度

//webview 高度
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *webViewConstraintHeight;

3 設置新的高度

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
CGRect frame = webView.frame;
	CGSize fittingSize = [webView sizeThatFits:CGSizeZero];
	frame.size = fittingSize;
	self.webViewConstraintHeight.constant = frame.size.height;
	}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章