Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/117.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法在iOS的WebView中获取动态html高度_Ios - Fatal编程技术网

无法在iOS的WebView中获取动态html高度

无法在iOS的WebView中获取动态html高度,ios,Ios,我们使用HandleBar js lib生成动态html,在iOS WebView加载html后,它只得到模板,高度不对。过了一会儿,模板中的图像已加载。页面已完成。但是我不能得到这个高度 我尝试了以下几种方法: 一, 二, -(void)observeValueForKeyPath:(NSString*)对象的键路径:(id)对象更改:(NSDictionary*)更改上下文:(void*)上下文 { if([keyPath IsequalString:@“contentSize”]) { N

我们使用HandleBar js lib生成动态html,在iOS WebView加载html后,它只得到模板,高度不对。过了一会儿,模板中的图像已加载。页面已完成。但是我不能得到这个高度

我尝试了以下几种方法:

一,

二,

-(void)observeValueForKeyPath:(NSString*)对象的键路径:(id)对象更改:(NSDictionary*)更改上下文:(void*)上下文
{
if([keyPath IsequalString:@“contentSize”])
{
NSInteger nextHeight=[[u webView\u wares stringByEvaluatingJavaScriptFromString:@“document.body.offsetHeight”]integerValue];
如果(_webViewHeight

但是上面所有的都没有得到正确的高度。谁来帮帮我

如果使用自动布局,则将“高度”约束设置为“web视图”,并创建该约束的出口

变量

float  heightWebview=0;
UIWebView *objWebView;
将HTML字符串传递给WebView(在CellForRowatineXpath中写入)

添加这两个表视图委托方法

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
  NSLog(@"Height Webview: %f", objWebView.scrollView.contentSize.height);
  heightWebview=objWebView.scrollView.contentSize.height;
  [objTableView reloadData];
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return UITableViewAutomaticDimension;
}

-(CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 44.0;
}

如果使用自动布局,则将“高度约束”设置为“web视图”,并创建此约束的出口

变量

float  heightWebview=0;
UIWebView *objWebView;
将HTML字符串传递给WebView(在CellForRowatineXpath中写入)

添加这两个表视图委托方法

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
  NSLog(@"Height Webview: %f", objWebView.scrollView.contentSize.height);
  heightWebview=objWebView.scrollView.contentSize.height;
  [objTableView reloadData];
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return UITableViewAutomaticDimension;
}

-(CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 44.0;
}

我没有使用故事板,我使用的是纯代码TableViewCell插入WebView。我需要得到的高度webView时,鱼负载。然后更新高度的细胞,以适应布局!谢谢你帮助我!我没有使用故事板,我使用的是纯代码TableViewCell插入WebView。我需要得到的高度webView时,鱼负载。然后更新高度的细胞,以适应布局!谢谢你帮助我!