我试图在 UITableViewController 上显示整行数据,而不是在 UITableViewController 上显示整列数据。
这是我在表格 View 上显示数据列的代码
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
Location *object;
object = [locationArray objectAtIndex:indexPath.row];
cell.nameLabel.text = object.name;
cell.descriptionLabel.text = object.address;
cell.publisherLabel.text = object.latitude;
return cell;
}
name
包含我数据库中的 Name
列
address
包含我数据库中的 Address
列
latitude
在我的数据库中保存 Latitude
列
And by doing this, my tableview will look like this
I want my tableview to display this
我完全不知道该怎么做。任何帮助将不胜感激,谢谢!
最佳答案
抱歉,格式设置无效,请参见下文
两种方法。
1)将您的记录数乘以 3。这就是您的总行数。所以如果有 5 条记录,则 5x3=15 行。然后在 cellforrowatindexpath
row 0 - name[0],
row 1 - Address[0],
row 2 - latitude[0],
row 3 - name[1]....
2) 以记录数作为节数。在每个部分中取 3 行。然后在 cellforrowatindexpath
row 0 section 0 - name[0],
row 1 section 0 - Address[0],
row 2 section 0 - latitude[0],
row 0 section 1 - name[1]....
关于ios - 如何在 iOS UITableViewController 上显示来自 phpMyAdmin 的一行数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35547243/