我正在将数据解析为表格视图,但服务器页面中有十万个名称。
首先,我在服务器端的不同页面中编写了所有服务器数据,并在表格视图下放置了一个“查看更多”按钮。当用户单击它时,页码将增加一并且第二页上的数据显示在表格视图中。问题是我在表格视图中丢失了第一页的数据。单击“查看更多”时,如何将新数据附加到以前的数据?
这是viewDidLoad
- (void)viewDidLoad
{
[super viewDidLoad];
sharedClass=[SharedClass sharedInstance];
[self.navigationController setNavigationBarHidden:YES];
Noresult.hidden = YES;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
// NSString *userid = [defaults objectForKey:@"userid"];
NSString *userid = @"3";
NSString *search_key = @"";
NSString *type=@"user";
page = 1;
ServerRequests *ser_req = [[ServerRequests alloc] init];
ser_req.server_req_proces = self;
NSString *postdata = [[NSString alloc] initWithFormat:@"{\"function\":\"search\", \"parameters\": {\"user_id\": \"%@\",\"search_key\": \"%@\",\"type\": \"%@\",\"page\": \"%d\"},\"token\":\"\"}",userid,search_key,type,page];
[ser_req sendServerRequests:postdata];
NSLog(@"array=========>>%@",postdata);
sharedClass.oprtn = @"load table";
}
这是viewMore
按钮内的代码
-(IBAction)Viewmore:(id)sender
{
NSString *userid = @"3";
NSString *search_key = searchBaar.text;
NSString *type=@"user";
page = page + 1 ;
ServerRequests *ser_req = [[ServerRequests alloc] init];
ser_req.server_req_proces = self;
NSString *postdata = [[NSString alloc] initWithFormat:@"{\"function\":\"search\", \"parameters\": {\"user_id\": \"%@\",\"search_key\": \"%@\",\"type\": \"%@\",\"page\": \"%d\"},\"token\":\"\"}",userid,search_key,type,page];
[ser_req sendServerRequests:postdata];
sharedClass.oprtn = @"load table";
}