我正在做一个项目,我想在 uitableview
中使用分页而不使用 api。我有一个 nsdictionary
并且我将该字典保存在一个 nsarray
中,现在我希望在 ListView 类型中有 10、20、30 个数字以及我选择的数字该数量的 rows
将显示在 UI 中。
我已经在 uitableview
-(UITableViewCell *)tableViewUITableView *)tableView cellForRowAtIndexPathNSIndexPath *)indexPath
{
NSString *string1 = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:string1];
if(!cell)
{
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:string1];
UILabel *label1 = (UILabel*)[cell.contentView viewWithTag:401];
CGFloat widthLabelHeader = CGRectGetWidth(orderTable.frame)/7;
if(!label1)
{
label1 = [[UILabel alloc]init];
label1.frame = CGRectMake(0, 0, widthLabelHeader, 45);
label1.layer.borderWidth = 0.5;
label1.font = [UIFont fontWithName"ChalkboardSE-Bold" size:14];
[cell.contentView addSubview:label1];
}
label1.textAlignment = NSTextAlignmentCenter;
UILabel *label2 = (UILabel*)[cell.contentView viewWithTag:402];
if(!label2)
{
label2 = [[UILabel alloc]init];
label2.frame = CGRectMake(CGRectGetMaxX(label1.frame), 0, widthLabelHeader, 45);
label2.layer.borderWidth = 0.5;
label2.font = [UIFont fontWithName"ChalkboardSE-Bold" size:14];
[cell.contentView addSubview:label2];
}
label2.textAlignment = NSTextAlignmentCenter;
UILabel *label3 = (UILabel*)[cell.contentView viewWithTag:403];
if(!label3)
{
label3 = [[UILabel alloc]init];
label3.frame = CGRectMake(CGRectGetMaxX(label2.frame), 0, widthLabelHeader, 45);
label3.layer.borderWidth = 0.5;
label3.font = [UIFont fontWithName"ChalkboardSE-Bold" size:14];
[cell.contentView addSubview:label3];
}
label3.textAlignment = NSTextAlignmentCenter;
UILabel *label4 = (UILabel*)[cell.contentView viewWithTag:404];
if(!label4)
{
label4 = [[UILabel alloc]init];
label4.frame = CGRectMake(CGRectGetMaxX(label3.frame), 0, widthLabelHeader, 45);
label4.layer.borderWidth = 0.5;
label4.font = [UIFont fontWithName"ChalkboardSE-Bold" size:14];
[cell.contentView addSubview:label4];
}
label4.textAlignment = NSTextAlignmentCenter;
UILabel *label5 = (UILabel*)[cell.contentView viewWithTag:405];
if(!label5)
{
label5 = [[UILabel alloc]init];
label5.frame = CGRectMake(CGRectGetMaxX(label4.frame), 0, widthLabelHeader, 45);
label5.layer.borderWidth = 0.5;
label5.font = [UIFont fontWithName"ChalkboardSE-Bold" size:14];
[cell.contentView addSubview:label5];
}
label5.textAlignment = NSTextAlignmentCenter;
UILabel *label6 = (UILabel*)[cell.contentView viewWithTag:406];
if(!label6)
{
label6 = [[UILabel alloc]init];
label6.frame = CGRectMake(CGRectGetMaxX(label5.frame), 0, widthLabelHeader, 45);
label6.layer.borderWidth = 0.5;
label6.font = [UIFont fontWithName"ChalkboardSE-Bold" size:14];
[cell.contentView addSubview:label6];
}
label6.textAlignment = NSTextAlignmentCenter;
UILabel *label7 = (UILabel*)[cell.contentView viewWithTag:407];
if(!label7)
{
label7 = [[UILabel alloc]init];
label7.frame = CGRectMake(CGRectGetMaxX(label6.frame), 0, widthLabelHeader, 45);
label7.layer.borderWidth = 0.5;
label7.font = [UIFont fontWithName"ChalkboardSE-Bold" size:14];
[cell.contentView addSubview:label7];
}
label7.textAlignment = NSTextAlignmentCenter;
dict1 = [array1 objectAtIndex:indexPath.row];
if( dict1)
{
label1.text = [dict1 objectForKey"key1" ];
label1.backgroundColor = [UIColor lightGrayColor];
label2.text = [dict1 objectForKey"key2" ];
label2.backgroundColor = [UIColor lightGrayColor];
label3.text = [dict1 objectForKey"key3" ];
label3.backgroundColor = [UIColor lightGrayColor];
label4.text = [dict1 objectForKey:@"key4" ];
label4.backgroundColor = [UIColor lightGrayColor];
label5.text = [dict1 objectForKey:@"key5" ];
label5.backgroundColor = [UIColor lightGrayColor];
label6.text = [dict1 objectForKey:@"key6" ];
label6.backgroundColor = [UIColor lightGrayColor];
label7.text = [dict1 objectForKey:@"key7" ];
label7.backgroundColor = [UIColor lightGrayColor];
}}
return cell;
}
请帮我怎么做?
使用此方法是方法并调用 Api 并附加到表数据源中使用的同一数组中
-(void)scrollViewDidEndDeceleratingUIScrollView *)scrollView
{
BOOL endOfTable = (scrollView.contentOffset.y >= ((showListingArray.count * 60) - scrollView.frame.size.height)); // Here 40 is row height
nextPage ++;
NSString *nextPageStr = [NSString stringWithFormat:@"%d", nextPage];
int totalpages = [[PaginnationDic objectForKey:@"totalPages"]intValue];
if ( endOfTable && !scrollView.dragging && !scrollView.decelerating)
{
if (nextPage >= totalpages) {
// NSLog(@"No More Page to load");
return;
}
objPCDetailTableView.tableFooterView = footerView;
NSDictionary *parametrs = @{@"movieid":_movieID, @"page":nextPageStr, @"cityId":[Utility getCityID]};
[self getMoviesDetailFromApi:parametrs];
[(UIActivityIndicatorView *)[footerView viewWithTag:10] startAnimating];
}
}
关于ios - 如何在不使用 Api 的情况下在 uitableview 中进行分页?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33213559/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |