Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/109.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios cell.textLabel setText包含多个项_Ios_Uitableview - Fatal编程技术网

Ios cell.textLabel setText包含多个项

Ios cell.textLabel setText包含多个项,ios,uitableview,Ios,Uitableview,我正在使用[cell.textlab setText:title];这很好,但我想在同一单元格中添加一些 例如: [cell.textLabel setText: title]; [cell.textLabel setText: venue]; [cell.textLabel setText: offer]; [cell.textLabel setText: title]; [cell.textLabel setText: venue]; [cell.textLabel setText: of

我正在使用[cell.textlab setText:title];这很好,但我想在同一单元格中添加一些

例如:

[cell.textLabel setText: title];
[cell.textLabel setText: venue];
[cell.textLabel setText: offer];

[cell.textLabel setText: title];
[cell.textLabel setText: venue];
[cell.textLabel setText: offer];

[cell.textLabel setText: title];
[cell.textLabel setText: venue];
[cell.textLabel setText: offer];

etc etc
但当然,这只是覆盖了前面的。所以我只是在每个单元格中得到“报价”

这样的事情是怎么做的?请记住,这是我的第一个应用程序,比“hello world”更上一层楼,所以如果这是一个愚蠢的问题,请原谅我:)


谢谢,

您可以像这样组合字符串:

NSString *celltext;

celltext = title;

celltext = [celltext stringByAppendingString:@" "];
celltext = [celltext stringByAppendingString:venue];
celltext = [celltext stringByAppendingString:@" "];
celltext = [celltext stringByAppendingString:offer];
[cell.textLabel setText: celltext];
替代解决方案:

NSString *celltext;
celltext = [celltext stringByAppendingFormat:@"%@ %@ %@", title, venue, offer];
[cell.textLabel setText: celltext];

谢谢@Bhumeshwer katre提供的信息。。。教人钓鱼


我建议任何遇到这个问题的人点击这个链接,这很容易做到,如果你是像我这样的初学者,你会学到很多东西:

你可以创建自定义单元格并向该单元格添加更多UILabel。。读这个。自定义单元格对此很好,但既然这是您的第一个应用程序,如果您想要一些简单的东西,为什么不添加标题、场地优惠并将其全部设置为一个标签呢?这两种方法的另一个考虑因素是你有房间吗?若你们并没有足够的水平空间,那个么一个定制的单元格可能就是你们想要的,你们可以根据需要调整它的大小,使你们的标签垂直。看这一节,把字符串混在一起的想法对我来说似乎是错误的。。。将导致样式问题和其他问题。所以我选择了贴在这里的自定义手机链接。真是太棒了!这个教训很清楚,但有点难以实现,因为引用不需要。但在玩了一会儿之后,我让它开始工作了。谢谢你的帮助@Bhumeshwerkatre,如果您添加此链接作为一种回答形式,我很乐意将其勾选为正确。一种效率很低的方法,可变字符串如何?这里不需要可变字符串。最好的是:celltext=
[celltext stringByAppendingFormat:@“%@%@%@”,标题,地点,优惠]但他提到他是个初学者,所以我选择了最容易理解的解决方案。@NikosM。不要教初学者坏习惯。
stringWithFormat:
没有什么难懂的。这是一个比你现在的答案更好的解决方案。向新开发人员传授正确的解决方案。使用
stringWithFormat:
NSMutableString
。我想知道在实际的运行时环境中到底有多少开销。我曾经处理过应用程序中的缓慢问题,我不确定这一点,除非有很多标签会创建一个。有了这些,我愿意了解如果有人有一些硬数字,负载差异是什么。