将 NSString 值分配给标签

发布于 2025-01-02 21:21:29 字数 275 浏览 2 评论 0原文

我尝试将 NSString 中的值应用到 IB 中的标签。我看到的问题是,分配给标签的值是:

UITextField: 0x6d4e0f0; frame = (7 86; 97 31); text = '2'; clipsToBounds = YES; opaque = NO; autoresize = RM+BM; layer = CALayer: 0x6d4e210

我显然只想看到“2”而不是整个 UITextfield 数据。

有什么线索吗?

I have tried to apply the value from a NSString to a label in IB. The problem im seeing, is that the value assigne to the label is:

UITextField: 0x6d4e0f0; frame = (7 86; 97 31); text = '2'; clipsToBounds = YES; opaque = NO; autoresize = RM+BM; layer = CALayer: 0x6d4e210

I obviously would like to just see "2" rather than the whole UITextfield data.

Any clues?

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

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

发布评论

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

评论(1

叹沉浮 2025-01-09 21:21:29

在你的标签中说:

[label setText: theTextField.text];

而不是:

[label setText: theTextField];

我的猜测是你传递整个 UITextField 对象,但你实际上只想传递它的 .text 部分。

对于您的评论:

NSString date = [NSString stringWithFormat:@"%@/%@/%@", day, month, year];

In your label say:

[label setText: theTextField.text];

Instead of:

[label setText: theTextField];

My guess is your passing the whole UITextField object, but you really just want to pass the .text part of it.

For your comment:

NSString date = [NSString stringWithFormat:@"%@/%@/%@", day, month, year];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文