Xcode(一个标签中的多个字符串)

发布于 2025-01-07 16:01:57 字数 125 浏览 7 评论 0原文

我有两个单独的字符串,我希望它们显示在同一个标​​签中。我如何使用 Xcode 做到这一点。

例如

第一个字符串称为answer1 第二个字符串称为answer2

我如何让我的标签同时显示

I have two separate strings and i want them displayed in the same label. How do i do that with Xcode.

for example

1st string is called answer1
2nd string is called answer2

how do i make my label display both

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

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

发布评论

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

评论(1

七婞 2025-01-14 16:01:57
[label setText:[NSString stringWithFormat:@"1st string is called %@ 2nd string is called %@", answer1, answer2]];

回答你的评论:
看看 NSString类参考stringByAppendingString:

NSString* string=@"";
for (int i=0; i<4; i++){
    string = [string stringByAppendingString:[NSString stringWithFormat:@"%d ", array[i]]];
}
[label setText:[NSString stringWithFormat:@"1st string is called %@ 2nd string is called %@", answer1, answer2]];

answering on your comment:
have a look at the NSString Class Reference Namely stringByAppendingString:

NSString* string=@"";
for (int i=0; i<4; i++){
    string = [string stringByAppendingString:[NSString stringWithFormat:@"%d ", array[i]]];
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文