Paginación en UITableview en ios
Frecuentes
Visto 2,080 equipos
0
I have a tableview in my application, into which I am loading different types of cells. I need to pass the page number to the service as one, two, etc. and to load that when the 1st page ends. For the first one I am loading the count is 10, after that when scroll ends I need to load the next. I am using Rest client Webservices. This is my json webservices.
{
"userId":2,
"encryptPassword":"50ec0d1b0559dbba51a58bed38aabf7bc6066641",
"pagination":{
"lastId":0,
"resultsPerPage":10
},
"status_id":1,
"request_type_id":2,
"isAgent":false,
"searchKey":""
}
2 Respuestas
4
Ok lets say you are pinging server for first 10 data and showing it into tableview
now what you have to do.
- Take a global
int
variable comoint lastLoadedId=0;
- When you parse your data simply store the last loaded id in
lastLoadedId
variable to track now where you are. - implementar el
-(void)scrollViewDidScroll: (UIScrollView*)scrollView
delegate method to know that you are at the bottom and you need new next data set.
-
-(void)scrollViewDidScroll: (UIScrollView*)scrollView
{
float scrollViewHeight = scrollView.frame.size.height;
float scrollContentSizeHeight = scrollView.contentSize.height;
float scrollOffset = scrollView.contentOffset.y;
if (scrollOffset + scrollViewHeight == scrollContentSizeHeight)
{
// you are in the end ping server with lastLoadedId for new data
}
}
-
- After getting new data set simply append them at the bottom of your
tableview
Respondido 12 Feb 14, 09:02
thanks for your response.But i had small doubt.after parsing how to store the last loaded id.please clarify my doubt or any sample code. - user3222991
last loaded id means you have keep track that how much data is loaded into table view from server. - Pal de tapas
@Tatpas pal thanks for your response.in response am getting request_id for each row which i have to pass as lastloadedid.how to get the requestid for last row in tableview... - user3222991
you must use an array. So simply pick the lastObject and get the last id. - Pal de tapas
@Tatpas Pal thanks for your response.But i had small doubt.How to get the lastOject ?please helpme.. - user3222991
0
The UITableView does not really have a concept of "pagination". It does have sections you might use. For example you could specify 10 sections with 10 cells (or rows) each. Each section can have a different number of cells.
Each section can have a header or a footer or both. You could put your page number into the footer of each section.
Respondido 12 Feb 14, 06:02
thanks for your response.But i have no idea this concept how to make this functionality.please give me any sample code or tutorial based on my above webservices... - user3222991
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas ios iphone objective-c or haz tu propia pregunta.
Seems like you have some good ideas, now just implement them buddy. - Marc
What seems to be the problem ? - n00bProgrammer
@n00bProgrammer thanks for your response.I have no idea of how to using pagination to the uitableview using webservices.... - user3222991