【问题标题】:numberOfLines in UITextview?UITextview中的numberOfLines?
【发布时间】:2010-12-21 13:46:57
【问题描述】:

UIlabel 具有 numberOfLines 属性。它说我的字符串有 2 行。但是当我使用 UItextview 时,我想根据 UITextview 中的文本长度来拆分行数。我该怎么做? UIlabel 自动拆分,但 UITextview 不这样做。

【问题讨论】:

    标签: iphone uitextview uilabel


    【解决方案1】:

    行应该用“\r”隔开

    这是一个例子:

    lblNeedSubscription = [[UILabel alloc] initWithFrame:frame];
    [lblNeedSubscription setNumberOfLines:0];  // allows as many lines as needed
    [lblNeedSubscription setText:@"To access content\ryou need to be a paid subscriber"];
    

    【讨论】:

      【解决方案2】:

      UITextView 本质上允许多行文本。你只需用“/n”字符分隔你的行,你就完成了。

      【讨论】:

      • 嗨,谢谢..但我想根据 UITextview 的长度分割行数,我该怎么做?有什么帮助吗?
      • 编辑问题,详细说明您希望实现的目标,让更多人能够更有效地帮助您。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-01-21
      • 1970-01-01
      • 2012-09-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-11
      • 1970-01-01
      相关资源
      最近更新 更多