我有一个问题,当我滚动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....
}我的代码中有什么错误吗?
发布于 2017-04-17 19:02:14
在您的整个类中实现了UITableView的哪些方法并不完全清楚。你至少应该有两个重要的方法:
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath这也是一个很好的this on AppCoda教程
https://stackoverflow.com/questions/43448834
复制相似问题