ios - cell.textLabel setText 包含多个项目

标签 ios uitableview

我正在使用 [cell.textLabel 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];

关于ios - cell.textLabel setText 包含多个项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20179274/

相关文章:

ios - 在 iOS 中缩放和平移 pdf 文件

ios - 改变笔划动画的方向

ios - uitableview:在同一行中,选定的按钮应自动选中,其余按钮应自动取消选中

ios - 如何以编程方式将按钮定位到带有边距的表格单元格的最右边缘?

ios - UITableViewCellAutomaticDimension 行为异常

ios - 制作像 iTunes 专辑页面这样的页面的最佳方法是什么?

ios - UITableView 由于在滚动 tableview 的同时重新加载数据而崩溃

ios - 如何在没有 UITabBarController 的情况下使用 UITabBar?

objective-c - 使用类别覆盖 NSURL 方法

c# - 推送通知未出现