How can i do some pagination with the parsed data in iOS
In my application i parsed some JSON RSS feed and stored the parsed data into a NSMutableArray.
here ,i want to display only 4 items in my tableview at a time . Below the tableview , there a UIButton 'more'. When the user clicks this button, i want to display another 4 like that ..... How to do that.
Can any one give me an idea or point me any simple example that i can refer . How开发者_如何转开发 can i do some pagination with the parsed data . Thanks in advance .......
http://www.iphonedevsdk.com/forum/iphone-sdk-development/6676-paging-tableview.html
As you already know there is a data source for a uiTableView. You can easily achieve this as your requirement needs a button press. Pagination without button press on scroll of the table view would be tricky.
You have to create a NSMutableArray
as a data source. Everytime the more button is pressed add 4 items to the end of the NSMutableArray
.
Using NSRange you can get the objects from the main array and add them 4 at a time to the data source. Once you add call [tableview reload]
;
Also you can create the data source again
NSArray *dataSource = [mainArray subarrayWithRange:NSMakeRange(0, PageNum*4)];
精彩评论