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

标签 ios uitableview

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

相关文章:

ios - Titanium - 从以前版本的 iOS 应用程序中检索 SQLite 数据

ios - 如何创建 CFArrayRef

ios - 即使在应用程序属性中设置了标志“位置”,CLLocationManager也会停止在后台更新位置

ios - 通过标签编辑 UITableViewCell

ios - UISearchBar 在搜索没有结果时显示标签,但在单击 UISearchBar 中的 x 时不会再次隐藏标签

ios - 解雇 Controller 委托(delegate)方法不起作用

html - 调整大小后 UIWebView 加载/排序错误

iphone - UINavigationController popViewControllerAnimated : crash in iOS 6

ios - 如何以编程方式在表格 View 中滚动

swift - 具有破坏性风格的 UIContextualAction 似乎默认删除行