如何在 UILabel 中放入法语字符?

发布于 2024-12-22 05:39:43 字数 288 浏览 1 评论 0原文

我正在从服务器获取 json,json 有一些属性,其中值是法语。当我将此法语字符串分配给 UILabel 时,它给了我空值。

我怎样才能把这个字符串放入 UILabel.

我正在这样做,

cell.title.text =[dealDictionary objectForKey:@"title"];
cell.description.text =[dealDictionary objectForKey:@"description"];

描述和标题都是法语。

I am fetching a json from server, json have some attributes where the value is in french. when I am assigning this french characters string to UILabel, it's giving me null.

How can I put this string in UILabel.

I am doing like this

cell.title.text =[dealDictionary objectForKey:@"title"];
cell.description.text =[dealDictionary objectForKey:@"description"];

description and title both are in French.

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

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

发布评论

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

评论(2

策马西风 2024-12-29 05:39:43

您确定 cell.title 存在并且它就是您所认为的那样吗?要说服自己这应该有效,请像这样更改代码:

cell.title.text = @"Même";

如果这不起作用,则 cellcell.title 有问题。

如果这有效,但您的代码不起作用,那么 [dealDictionary objectForKey:@"title"] 是什么类型的对象可能有些有趣。尝试将其分配给 NSString 并查看执行时会得到什么。

换句话说,您在一行代码中做出了太多假设。分解每个假设并进行测试。这就是如何调试。

Are you certain that cell.title exists and that it is what you think it is? To persuade yourself that this should work, change your code like this:

cell.title.text = @"Même";

If that doesn't work, there's something wrong with cell or with cell.title.

If that works but your code doesn't, then perhaps there is something funny about what kind of object [dealDictionary objectForKey:@"title"] is. Try assigning it to an NSString and see what you get when you do.

In other words, you are making too many assumptions in a single line of code. Break down each assumption and test it. That is How To Debug.

去了角落 2024-12-29 05:39:43

您使用了错误的属性来设置文本。请务必检查文档

cell.textLabel.text = [dealDictionary objectForKey:@"title"];
cell.detailTextLabel.text = [dealDictionary objectForKey:@"description"];

为了使detailTextLabel可见,它需要是支持它的样式。

UITableViewCellStyleValue1

单元格左侧带有标签的单元格样式
左对齐和黑色文本;右侧是一个标签,上面有
较小的蓝色文本并且右对齐。设置应用程序使用
这种样式的单元格。

UITableViewCellStyleValue2

单元格的样式,单元格左侧有一个带文本的标签
右对齐且蓝色;单元格的右侧是
另一个带有较小文本的标签,左对齐且黑色。这
电话/联系人应用程序使用这种样式的单元格。

UITableViewCellStyleSubtitle

单元格的样式,其顶部有一个左对齐的标签,
其下方的左对齐标签以较小的灰色文本显示。 iPod 应用程序
使用这种样式的单元格。

You are using the wrong property to set the text. Make sure you check the documentation.

cell.textLabel.text = [dealDictionary objectForKey:@"title"];
cell.detailTextLabel.text = [dealDictionary objectForKey:@"description"];

For the detailTextLabel to be visible it needs to be a style that supports it.

UITableViewCellStyleValue1

A style for a cell with a label on the left side of the cell with
left-aligned and black text; on the right side is a label that has
smaller blue text and is right-aligned. The Settings application uses
cells in this style.

UITableViewCellStyleValue2

A style for a cell with a label on the left side of the cell with text
that is right-aligned and blue; on the right side of the cell is
another label with smaller text that is left-aligned and black. The
Phone/Contacts application uses cells in this style.

UITableViewCellStyleSubtitle

A style for a cell with a left-aligned label across the top and a
left-aligned label below it in smaller gray text. The iPod application
uses cells in this style.

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