gpt4 book ai didi

ios - 如果标签文本为空,则填写文本

转载 作者:行者123 更新时间:2023-11-28 19:54:15 24 4
gpt4 key购买 nike

我从 RSS 提要中提取信息,有时 title 和/或 description 是空白的,所以它会显示UITableViewCell 中的空白。

所以如果 title 和/或description空白,我想将其填写为 Title 和/或 Description

我有什么:

    cell.labelHeadline.text = title;
cell.labelDescription.text = description;

我尝试了什么:

   if ([cell.labelHeadline.text isEqualToString:@""]) {
cell.labelHeadline.text = @"Title";
} else {
cell.labelHeadline.text = title;
}

if ([cell.labelDescription.text isEqualToString:@""]) {
cell.labelDescription.text = @"Description";
} else {
cell.labelDescription.text = description;
}

我试过的方法不起作用...有什么想法吗?

将根据需要发布任何额外的代码,谢谢!

最佳答案

在您的情况下,您检查的是放置在单元格中的标签值,而不是从服务器获取的值。而不是你需要检查从服务器检索的值,我想你想改变你的条件,比如:

    if ([title isEqualToString:@""])
{
cell.labelHeadline.text = @"Title";
}
else
{
cell.labelHeadline.text = title;
}

if ([description isEqualToString:@""])
{
cell.labelDescription.text = @"Description";
}
else
{
cell.labelDescription.text = description;
}

关于ios - 如果标签文本为空,则填写文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27391641/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com