当我滚动UITableView
时出现问题,第一次显示两行后,当我滚动到第三行时,它再次显示第三行的第一行数据。
我使用过这段代码:
static NSString *CellIdentifier = @"inviCell1";
inviProfileCell *cell1 =
(inviProfileCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell1.selectionStyle = UITableViewCellSelectionStyleNone;
if(cell1 == nil) {
cell1 = [[inviProfileCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] ;
}
Obj=[[ObjClass alloc]init];
Obj=[fetchedArray objectAtIndex:0];
UIButton *btn1 = (UIButton *)[cell1 viewWithTag:101];
UIButton *btn2 = (UIButton *)[cell1 viewWithTag:102];
UIButton *btn3 = (UIButton *)[cell1 viewWithTag:103];
UIButton *btn4 = (UIButton *)[cell1 viewWithTag:104];
UIButton *btn5 = (UIButton *)[cell1 viewWithTag:105];
UIButton *btn6 = (UIButton *)[cell1 viewWithTag:106];
cell1.moreBtn.tag = indexPath.row+1;
cell1.moreBtn.userInteractionEnabled = YES;
if (inviLoadCount > indexPath.row+1) {
cell1.moreBtn.hidden = YES;
}else{
cell1.moreBtn.hidden = NO;
}
int maxindex = (int)(6*(indexPath.row+1));
int startIndex = (int)(6*indexPath.row);
int counter = 1;
NSLog(@"%lu",(unsigned long)boast_Obj.purchase_array.count);
for (int i = startIndex; i < maxindex; i++) {
// functionality....
}
我的代码有什么问题吗?
答案 0 :(得分:0)
在您的全班中,UITableView
的哪些方法实施并不完全清楚。你应该至少有两个重要的方法:
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
的好教程