gpt4 book ai didi

ios - 如何在 iOS UITableViewController 上显示来自 phpMyAdmin 的一行数据

转载 作者:行者123 更新时间:2023-11-28 21:32:06 25 4
gpt4 key购买 nike

我试图在 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

下面是我使用 phpmyadmin 的数据库表 enter image description here

And by doing this, my tableview will look like this

enter image description here

I want my tableview to display this

enter image description here

我完全不知道该怎么做。任何帮助将不胜感激,谢谢!

最佳答案

抱歉,格式设置无效,请参见下文
两种方法。
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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com