step 1 设定uiwebview一个固定的高度值(设置一个合适的高度)
step 2 添加一个高度的引用
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *webViewHeightConstraint;
step 3 添加UIWebViewDelegate 并设置自身delegate
step 4
- (void)webViewDidFinishLoad:(UIWebView *)webView {
[self.webDoctorReminder sizeToFit];
self.webViewHeightConstraint.constant = self.webDoctorReminder.frame.size.height;
}
参考原文 https://stackoverflow.com/questions/17510135/dynamic-uiview-height-with-auto-layout-in-ios-6