问题描述
我是 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 的快捷方式
所以:
self.textLabel.text = [@"Hi" stringByAppendingString: self.textField.text]
或
[textLabel setStringValue: [@"Hi" stringByAppendingString: self.textField.text]];
这篇关于Xcode:如何获取 textLabel 以显示在 textField 中输入的附加静态文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!