UITableview , dynamically section & rows

我的梦境 提交于 2019-12-02 05:07:34

You have a problem in your mapping of indexPaths to the rows of your data structure (in this case, your items array). Each section will be numbered from 0 to ceil(n/2) (which, by the way, should be the number of sections, not simply n/2) where n is the number of elements in items.

Each row inside the section will have an indexPath.row of 0 or 1.

Therefore, in order to map from indexPaths back to your items array, you have to do something like this in your cellForRowAtIndexPath function:

NSString *text = [items objectAtIndex:([indexPath section]*2 + [indexPath row])];

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!