Xcode:如何获取 textLabel 以显示在 textField 中输入的附加静态文本? [英] Xcode: How do I get a textLabel to display addition static text that is being entered in the textField?

查看:32
本文介绍了Xcode:如何获取 textLabel 以显示在 textField 中输入的附加静态文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Xcode 新手,请帮忙.

I am a Xcode newbie, please help.

所以我知道如何使用文本字段更改标签框中的文本:

So I know how to change the text in Label box by with a text field:

self.textLabel.text = self.textField.text

self.textLabel.text = self.textField.text

问题是:如何将静态文本添加到正在输入的文本中?

The question is: how do I add static text to text that is being entered?

就像在 textField 中输入名称一样,如何让标签框显示Hi",然后输入任何文本?

Like if in the textField a name is entered, how do get the label box to display a "Hi," then whatever text that was entered?

在="符号之后的self.textField.text"前面需要放什么?

What do I have to put in front of "self.textField.text" after the "=" sign ?

谢谢

推荐答案

您需要连接 2 个字符串.这里有一些线索:

You need to concatenate 2 Strings. Here are some clues:

Objective-C 中连接 NSStrings 的快捷方式

在字符串 Objective-c 中连接字符串

Objective C 中的简单字符串连接

所以:

self.textLabel.text = [@"Hi" stringByAppendingString: self.textField.text]

[textLabel setStringValue: [@"Hi" stringByAppendingString: self.textField.text]];

这篇关于Xcode:如何获取 textLabel 以显示在 textField 中输入的附加静态文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆