gpt4 book ai didi

iphone - UI Scroll View 中的文本内容大小,底部的文本被截断

转载 作者:行者123 更新时间:2023-12-03 20:15:49 24 4
gpt4 key购买 nike

我有 UIScroll,里面有 uitextview。

我的应用程序如下所示:

rootviewcontroller -> PhoneContentController(UIScrollViewPageControl)-> DetailController (UITextViewUIWebViewUILabel)。

我的流程是这样的:

设置UIScrollView默认大小 -> 调用DetailController(在viewDidLoad中计算UITextView和其中的其他页面) -> PhoneContentControllerDetailController 获取总高度大小 -> 更改 UIScrollView 的高度

这是 PhoneContentController 中的代码 (loadSCrollViewWithPage):

scrollView.contentSize = CGSizeMake(scrollView.frame.size.width * kNumberOfPages, [detailController.getTotalHeight]);

详细 Controller 中的代码(viewDidLoad):

summaryBlogParsed = [summaryBlogParsed stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
[self.itemSummaryText setText:summaryBlogParsed];

CGRect frameTextView = self.itemSummaryText.frame;

frameTextView.size.height = self.itemSummaryText.contentSize.height;

self.itemSummaryText.frame = frameTextView;

DetailController 中的这段代码 getTotalHeight:

 CGRect cgRect = [[UIScreen mainScreen] bounds];

CGFloat scrollFrame = (cgRect.size.height/2) + itemSummaryText.frame.size.height;

return scrollFrame;

我可以滚动 ScrollView ,但 textview 无法加载所有字符串。只喜欢一半,但我可以向下滚动,但有空白页:(。

有人可以帮助我吗?

谢谢

最佳答案

使用此函数设置 ScrollView 的内容大小。

-(void)setContentSizeOfScrollView:(UIScrollView*)scroll
{
CGRect rect = CGRectZero;

for(UIView * vv in [scroll subviews])
{
rect = CGRectUnion(rect, vv.frame);
}

[scroll setContentSize:CGSizeMake(rect.size.width, rect.size.height)];
}

将所有控件添加到 ScrollView 后,调用此函数并传递 yourScrollView 作为参数。希望这对您有帮助............

关于iphone - UI Scroll View 中的文本内容大小,底部的文本被截断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7823229/

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