如何在表视图中划分数组并显示? [英] How divide array and show in table view?

查看:50
本文介绍了如何在表视图中划分数组并显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发表格视图.为了填写该表,我有75个内容的数组.现在,我想像第一次显示表格视图一样显示表格视图,然后仅显示10行数组和一个标题显示更多的按钮.当单击按钮时,在表视图中显示数组的下10个内容,在表视图的最后一个中显示上一个和下两个按钮.当单击next时,则再次显示数组的下10个内容;单击previous时,则显示前10个内容.现在的问题是,我将如何处理数组,以便获得这种类型的外观?在表视图中如何编写代码?

I am developing a table view. To fill that table i have an array of 75 content. Now i want to show table view like as when first time shown table view then show only 10 row of array and one button whose title is show more. when click on button then show next 10 content of array in table view and in last of table view show two button previous and next. When click on next then again show next 10 content of array and when click on previous then show previous 10 content. Now problem is that what i will do with array so that i get this type look? How code for that in table view?

推荐答案

您可以像下面这样去.

1 ..假设n = 11

1.. Take a variable suppose n=11

2 ..在 cellForRowAtIndexPath 中只为 n-1 个单元格编写代码...,为 nth 个单元格创建一个代码您所说的显示更多的时间

2.. in cellForRowAtIndexPath write a code for only n-1 cells... and for nth cell create a button for first time that shows show more as you said

3 ..现在,在 didSelectRowAtIndexPath 中编写代码以标识所选单元格的索引== n?如果是,则调用一个方法,该方法将使n增加10,然后再次重新加载表.

3.. Now in didSelectRowAtIndexPath write a code to identify that the selected cell has index == n?? if yes then call a method which will increment n with 10 and then again reload table.

4 ..根据需要继续递增和递减n ...,但请记住要在第n行选择的情况下重新加载数据

4.. Go on incrementing and decrementing n as you want... but remember to reload data with nth row selection

这篇关于如何在表视图中划分数组并显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆