简体   繁体   English

iPhone:如何在选项卡视图中添加可滚动文本

[英]iPhone: How to add a scrollable text in a tab view

Looking for some guidance.寻求一些指导。

In my main window nib file, i have a tab controller where each tab control item is being loaded by a separate nib file and controller.在我的主要 window nib 文件中,我有一个选项卡 controller,其中每个选项卡控件项都由单独的 nib 文件和 controller 加载。 One of the tab items is being loaded by a navigation controller.导航 controller 正在加载其中一个选项卡项。 Looks like this (excuse me for not including screenshot)看起来像这样(请原谅我不包括截图)

  • MainWindow.xib主窗口.xib
    • Windows Windows
    • UITabBarController UITabBarController
      • UITabBar UITabBar
      • UINavigationController (loaded from Test.xib file) UINavigationController(从 Test.xib 文件加载)
        • TabBar Item标签栏项
  • Test.xib测试.xib
    • View看法

Now I like to add a scrollable text in the Test.xib.现在我想在 Test.xib 中添加一个可滚动的文本。 So that when the user clicks on the tab item, my Test view opens up with some text that the user can scroll.因此,当用户单击选项卡项时,我的测试视图会打开一些用户可以滚动的文本。

Do I need to add a UITextView as a child of my View in Test.xib?我是否需要在 Test.xib 中添加 UITextView 作为我的 View 的子项? Do I need to add a UIScrollableView?我需要添加 UIScrollableView 吗? And how would I connect them all so that I can manage the text.我将如何将它们全部连接起来以便我可以管理文本。

Yes, UITextView needs to be a child of your View in Test.xib (you can add it programatically if you like or through IB).是的,UITextView 需要是您在 Test.xib 中的 View 的子项(如果您喜欢或通过 IB 可以通过编程方式添加它)。 You do not need a UIScrollableView.您不需要 UIScrollableView。 The textview will scroll as long as you set scrollEnabled = YES;只要您设置 scrollEnabled = YES,textview 就会滚动;

Not sure what you mean by "how would I connect them so I can manage the text".不确定“我将如何连接它们以便我可以管理文本”是什么意思。 You can send the UITextView a message of setText to whatever text you want in there.您可以向 UITextView 发送一条 setText 消息到您想要的任何文本。 Hope that helps some!希望能有所帮助!

If you add an UITextView to your view, connect it to a proper Outlet in your controller, than you can manipulate the text with setText: .如果您将UITextView添加到您的视图中,请将其连接到 controller 中的适当插座,然后您可以使用setText:操作文本。 The scrolling behaviour is added automatically.滚动行为是自动添加的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM