【问题标题】:UITextView not loading/showing the large text?UITextView 不加载/显示大文本?
【发布时间】:2013-01-04 09:32:20
【问题描述】:

我的登录屏幕中有一个简单的 UITextView,我需要在其中显示条款和条件。条款和条件中有一个非常大的文本。在界面构建器中,我已将文本添加到 UITextView。在界面生成器中,文本正在正确显示。但是当我运行应用程序时 UITextView 是空的。如果我在 UItextView 中给出小文本,它会正确呈现,但不会显示大/大文本。


这里是代码。

- (IBAction)showTermsOfUse:(id)sender{
    termsOfUseText.text = @"/***/";
    termsOfUseText.scrollEnabled = YES;

    [UIView beginAnimations:nil context:nil]; // begins animation block
    [UIView setAnimationDuration:0.6];        // sets animation duration
    [UIView setAnimationDelegate:self];
    termsOfUse.frame = CGRectMake(0,0,320,416);
    [UIView commitAnimations];   // commits the animation block.  This Block is done.
}

【问题讨论】:

  • 它是否被截断或向上滚动?
  • 启用 textview 的滚动
  • 它根本不显示/显示文本。是的.. 启用滚动。
  • 你连接插座了吗? :p
  • @AnoopVaidya 我只在界面生成器中给出了文本,所以不需要将它连接到任何出口仪式?

标签: ios objective-c xcode uitextview


【解决方案1】:

通过以编程方式提供文本....和

termsofUseText.text =   @"MY LARGE TEXT GOES HERE......    "
termsOfUseText.scrollEnabled = YES;
termsOfUseText.userInteractionEnabled = YES;
termsOfUseText.editable = NO;

【讨论】:

    【解决方案2】:

    以编程方式创建此UITextView

    UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(AsYouNeed)];
    [textView  setFont: [UIFont fontWithName:@"YourFontName" size:YourSize]];
    textView.text = @"test my font size";
    [textview setUserInteractionEnabled:TRUE];  
    [self.view addSubview:textView];
    [textView release];
    

    【讨论】:

    • 他想要一个 textView 而不是 textfeild
    • @Dhara - 对不起..我改变了:)
    • [textview setUserInteractionEnabled:TRUE]; 解决了你的滚动问题:)
    【解决方案3】:

    我也遇到过同样的问题,我解决了这个问题,我使用 UITextView 的 IBOutlet 并像这样在代码中设置值

    UITextView *txtView=[[UITextView alloc] initWithFrame:CGRectMake(50, 50, 200, 200)];
    [txtView setText:@"Your long text"];
    [txtView setEditable:NO];
    [self.view addSubview:txtView];
    [txtView release];
    

    另一种选择是使用 webview 并在 webview 中加载您的内容。

    【讨论】:

    • 通过代码添加对我来说效果很好。你是如何添加的,你能显示你的代码吗?
    • 在您的上述答案中.. 如果我们使 textview 用户交互可编辑,它将正常工作。
    猜你喜欢
    • 1970-01-01
    • 2017-09-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-13
    • 2011-01-28
    相关资源
    最近更新 更多