【问题标题】:How to provide RTLabel and ScrollView height according to the content?如何根据内容提供 RTLabel 和 ScrollView 高度?
【发布时间】:2014-08-19 23:07:52
【问题描述】:

我正在使用平台 Xcode(5.1) 为 iPhone 创建一个 iOS 文章阅读应用程序并选择模板 Empty 应用程序。

我正在使用RTLabel lib 来解析ScrollView 中的html 数据。 超链接不起作用。 我在根据内容管理RTLabel 高度时遇到问题(内容大小不固定)。 ScrollView 包含UILabelUIImageRTLabel,它正在工作,但我想根据内容管理滚动高度。

我应用了此代码,但它不起作用。

RTLabel *label = [[RTLabel alloc] initWithFrame:CGRectMake(10, 400, 310, 600)];

[self->scroller addSubview:label];

[label setText:_DetailModal1[3]];

[scroller setScrollEnabled:YES];

CGFloat scrollViewHeight = 0.0f;

  for (label in scroller.subviews)  {

 scrollViewHeight += label.frame.size.height;   }

 [scroller setContentSize:(CGSizeMake(320, scrollViewHeight))];

感谢您的帮助。

【问题讨论】:

    标签: ios objective-c uiscrollview xcode5 html-parsing


    【解决方案1】:

    CGSize 最佳尺寸 = [标签最佳尺寸];
    label.frame = CGRectMake(label.frame.origin.x, label.frame.origin.y, label.frame.size.width,optimumSize.height+10);
    scroller.contentSize = CGSizeMake(scroller.frame.size.width, label.optimumSize.height);

    【讨论】:

      猜你喜欢
      • 2018-11-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-12
      • 1970-01-01
      • 2014-09-29
      • 2014-12-09
      相关资源
      最近更新 更多