gpt4 book ai didi

iphone - 如何在 iPhone 中查找 Scroll View 或 WebView 内容的高度

转载 作者:行者123 更新时间:2023-12-01 19:10:26 24 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





How to determine the content size of a UIWebView?

(15 个回答)


8年前关闭。



 UIScrollView *ScrollView=[[UIScrollView alloc]initWithFrame:CGRectMake(0,0,320,600)];
ScrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth ;
ScrollView.autoresizesSubviews = YES;

[ScrollView setContentSize:CGSizeMake(320, 2500)];

ScrollView.scrollEnabled = YES;

ScrollView.directionalLockEnabled = YES;

ScrollView.showsVerticalScrollIndicator = NO;

ScrollView.showsHorizontalScrollIndicator = NO;

ScrollView.autoresizesSubviews = YES;
ScrollView.backgroundColor=[UIColor whiteColor];
[self.view addSubview:ScrollView];

UIwebview *webView = [[UIWebView alloc]initWithFrame:CGRectMake(10,30,310,1500)];
webView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight) ;
webView.autoresizesSubviews = YES;

NSLog(@"vlaue od v is %@",webView);

webView.scrollView.scrollEnabled = NO;
webView.scrollView.bounces = NO;

//make the background transparent
[webView setBackgroundColor:[UIColor clearColor]];

//pass the string to the webview

[webView loadHTMLString:[html description] baseURL:nil];
NSLog(@"web view is %f",webView.scrollView.contentSize.width);
[webView sizeThatFits:CGSizeZero];
NSLog(@"web view is %@",webView);

//add it to the subview
NSLog(@"height: %d", [[webView stringByEvaluatingJavaScriptFromString:@"document.body.offsetHeight"] intValue]);

// CGFloat contentHeight = webView.scrollView.contentSize.height;
// ScrollView.contentSize = webView.scrollView.contentSize.frame.size;
// NSLog(@"scroll size is %d",ScrollView.contentSize);

// [UIScrollView setNeedsDisplay];

[ScrollView addSubview:webView];

NSLog(@"size is %f",ScrollView.contentSize.height);

我是这个领域的初学者。我已经应用了所有这些东西,我想在 ScrollView 上添加 webview 数据然后 ScrollView 上的内容长度像我定义的 2500 高度然后覆盖 1000,1500

最佳答案

您可以使用以下方法找到 ScrollView 高度

- (void)webViewDidFinishLoad:(UIWebView *)webView {
int contentHeight = myWebView.scrollView.contentSize.height;
Nslog(@"%d",contentHeight);
}

关于iphone - 如何在 iPhone 中查找 Scroll View 或 WebView 内容的高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16910117/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com