ios - 向 TableView 单元格添加副标题

标签 ios objective-c xcode uitableview

我正在尝试为我的 TableView 显示副标题,但我一直收到一条错误消息,提示“分配给只读属性”我部署文本的代码是

cell.textLabel.text = [arrayData objectAtIndex:indexPath.row];
cell.detailTextLabel = [arraySubtitle objectAtIndex:indexPath.row];

return cell;

但是在第二行,我得到了错误!请帮我!谢谢! ( objective-c )

最佳答案

您正在尝试将值(可能是字符串)分配给 cell 的标签,而不是单元格标签的文本(属性)。
试试这个....

cell.textLabel.text = [arrayData objectAtIndex:indexPath.row];
cell.detailTextLabel.text = [arraySubtitle objectAtIndex:indexPath.row];  // Update here, 

return cell;

关于ios - 向 TableView 单元格添加副标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42463727/

相关文章:

objective-c - GKSession connectToPeer 方法不会超时

ios - 调整 iOS 11 上的 UI 导航

objective-c - 为什么 CGSize 在声明变量时不使用 *?

iphone - iPhone:如何从viewForAnnotation方法的类中获取值?

ios - 如何同时使用水平和垂直 ScrollView (快速)

iphone - 在 HTTP 多部分/表单数据内容类型中转义 CRLF (iOS)

ios - 如何在出现键盘时向上移动两个 UIView?

objective-c - 在 Objective C 中拥有私有(private)成员的不同方式的比较

xcode - OSX HUD 面板 全透明

xcode - Xamarin Forms 显示缓存的签名身份