如何将文本发送到 UITextView?

发布于 2024-09-01 07:49:05 字数 664 浏览 3 评论 0原文

我是 iPhone 开发新手。我是一名 VB 程序员,正在尝试将 VB 应用程序转换为 ipad 应用程序。

我需要一些帮助来将文本发送到 UITextView。

我想首先有一个 UIPickerView,然后一旦用户点击 UIButton,就会出现一个 UITextView,然后由我的源代码逐行生成文本。代码会不断地将字符串连接到文本。

它有点像这样——

  1. 用户使用 UIPickerView 进行选择。
  2. 然后用户点击 UIButton。
  3. UIPickerView 在屏幕上被替换为 UITextView。
  4. 代码做了一些事情。
  5. 该代码将第一行文本添加到 UITextView 中。
  6. 代码做了更多的事情。
  7. 然后,代码将第二行文本添加到 UITextView 中,并保留已经存在的第一行。

重复步骤 6 和 7,直到代码完成。

有谁知道我可以看一下这方面的任何例子吗?我最感兴趣的是找到一些东西,比如 YouTube 视频、解释代码的网页,甚至是一本涵盖这个特定主题的好书。我发现苹果公司在这个网站上提供的示例代码超出了我的理解范围。

事实上,我可能会从一本好书中受益。但是,我正在寻找一个我已经知道涵盖这个特定主题的主题,因为它对于我正在尝试构建的应用程序非常重要。

I'm new to iphone development. I'm a VB programmer who is trying to convert a VB application to an ipad app.

I need some help with sending text to a UITextView.

I want to first have a UIPickerView and then once the user hits a UIButton, a UITextView appears and the text is then generated by my source code code, line by line. The code would constantly be concatenating strings to the text.

It would sort of go like this--

  1. User makes selections with UIPickerView.
  2. User then hits UIButton.
  3. UIPickerView is replaced on the screen with a UITextView.
  4. The code does stuff.
  5. The code adds the 1st line of text into the UITextView.
  6. The code does more stuff.
  7. The code then adds the 2nd line of text into the UITextView, retaining the 1st line that was already there.

Steps 6 and 7 are repeated until the code is done.

Does anyone know of any examples of this that I could look at? I am mostly interested in finding something like a youtube video, a webpage that explains the code or even a good book that covers this particular topic. I am finding that the sample codes that Apple has on this site goes over my head.

In fact, I could probably benefit from a good book. But, I am looking for one that I would already know covers this particular topic, since it is so essential to the app that I am trying to build.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

念三年u 2024-09-08 07:49:05

将文本附加到 UITextView 是相当简单:

uiTextView.text = [NSString stringWithFormat:@"%@ %@", uiTextView.text, textToAppend];

就一本好书而言,我喜欢iPhone SDK Development< /a> 和开始 iPhone 3 开发

Appending text to a UITextView is fairly simple:

uiTextView.text = [NSString stringWithFormat:@"%@ %@", uiTextView.text, textToAppend];

As far as a good book, I've liked iPhone SDK Development and Beginning iPhone 3 Development.

千柳 2024-09-08 07:49:05

我无法弄清楚当用户点击 UIButton 时如何使 GUI 被 UITextView 替换。

您可以:

I'm having trouble figuring out how, when the user hits the UIButton, how to make the GUI be replaced by a UITextView.

You could:

  • Make the button hidden and the text-view visible
  • Remove the button from the view and add the text view
白衬杉格子梦 2024-09-08 07:49:05

我本来就已经在那里了,只是隐藏起来。然后取消隐藏并添加文本,NSString 有多种辅助函数(文本是 NSString)。

Safari Books Online 和 Lynda 是我最喜欢的资源,但 iTunes 上也有免费的东西。

您需要使用按钮设置 IBAction,当按下按钮时,您将 UITextView 的隐藏设置为 NO 并执行类似于其他答案的附加操作。我喜欢这个版本:

textView.text = [textView.text stringByAppendingString:@"Other stuff I\'m appending"];

I would have it already there, just hidden. Then unhide it and add the text, NSString has a variety of helper functions (and the text is NSString).

Safari Books Online and Lynda are my favorite resources, but there's free stuff on iTunes as well.

You need to setup IBAction with the button, and when it's hit, you'll set the UITextView's hidden to NO and do something like the other answer's appending. I like this version of:

textView.text = [textView.text stringByAppendingString:@"Other stuff I\'m appending"];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文