【问题标题】:One section per row in a UITableViewUITableView 中每行一个部分
【发布时间】:2013-08-12 08:19:33
【问题描述】:

我正在尝试创建一个 UITableView,每个部分有一行,以呈现消息聊天表的外观。如何实现这一目标?使用 [数组计数] 在下面两个委托方法的不同组合中,要么返回同一单元格的不同部分,要么返回每个部分中的多行。

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return [array count];}    

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 1;}

【问题讨论】:

    标签: objective-c uitableview row tableview


    【解决方案1】:

    看起来它应该做你想做的事。那么在cellForRowAtIndexPath:中取出数组元素时,需要使用索引路径中的section属性,而不是row。

    【讨论】:

      【解决方案2】:

      修复它:

      [Array objectAtIndex:indexPath.section];
      

      使用“节”而不是“行”。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-10-14
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多