简体   繁体   English

在SQLite文件和iPhone uitableview中使用分区表

[英]Using sectioned tables from an sqlite file with an iPhone uitableview

I am currently trying to make a sectioned table like this: 我目前正在尝试制作一个像这样的分段表:

Section 1: Entry 1 Entry 2 Entry 3 第1节:条目1条目2条目3

Section 2: Entry 4 Entry 5 Entry 6 第2节:条目4条目5条目6

Section 3: Entry 7 Entry 8 ... 第3节:条目7条目8 ...

However, using this code: 但是,使用此代码:

Event *lists = (Event *)[eventList objectAtIndex:indexPath.row]; 事件*列表=(事件*)[事件列表objectAtIndex:indexPath.row];

accessStatement = "select * from DatabaseName"; accessStatement =“从数据库名中选择*”;

[self findEvents]; [self findEvents]; // Code that builds each object's strings from database //从数据库构建每个对象的字符串的代码

cell.textLabel.text = lists.name; cell.textLabel.text =列表名称;

Section 1: Entry 1 Entry 2 Entry 3 第1节:条目1条目2条目3

Section 2: Entry 1 Entry 2 Entry 3 第2节:条目1条目2条目3

Section 3: Entry 1 Entry 2 ... 第3节:条目1条目2 ...

It keeps on repeating itself. 它不断重复。 How do I make the index so that it continues in each section rather than restarts? 如何制作索引,使其在每个部分中都继续而不是重新启动?

Thanks in advance. 提前致谢。

The row will start from zero at each section. 该行将从每个部分的零开始。 You can get your index into the database by multiplying the number of rows you want per section with the indexPath.section parameter: 通过将每个部分所需的行数乘以indexPath.section参数,可以使索引进入数据库:

Event *lists = (Event *)[eventList objectAtIndex:(indexPath.section * 3) + indexPath.row];

Claus 克劳斯

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM