我有一个从Parse填充的UItableview,我在cellForRowAtIndexPath中有几个按钮就像这样
UIbutton *buttonTwo = (UIButton *)[cell viewWithTag:2];
buttonTwo.selected = NO;
[[buttonTwo layer] setBorderWidth:2];
[[buttonTwo layer] setBorderColor:[UIColor blackColor].CGColor];
UIButton *buttonOne = (UIButton *)[cell viewWithTag:6];
[buttonOne addTarget:self action:@selector(buttonOne:) forControlEvents:UIControlEventTouchUpInside];
[[buttonOne layer] setBorderWidth:2];
[[buttonOne layer] setBorderColor:[UIColor blackColor].CGColor];
问题在于,例如,当填充5个单元格时,并非每个单元格都会加载按钮,但是当我单击刷新数据的按钮时,它就会出现。生病链接图片。
因此大的白色空间将是一个图像。但是在顶部它有按钮1和按钮2,两者都正确加载,但在第二行button2没有正确加载,其无效直到我点击刷新重新加载解析数据,然后按钮的边框显示,可点击。
以下是更多代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object {
static NSString *CellIdentifier = @"PhotoCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
UIbutton *buttonTwo = (UIButton *)[cell viewWithTag:2];
buttonTwo.selected = NO;
[[buttonTwo layer] setBorderWidth:2];
[[buttonTwo layer] setBorderColor:[UIColor blackColor].CGColor];
UIButton *buttonOne = (UIButton *)[cell viewWithTag:6];
[buttonOne addTarget:self action:@selector(buttonOne:) forControlEvents:UIControlEventTouchUpInside];
[[buttonOne layer] setBorderWidth:2];
[[buttonOne layer] setBorderColor:[UIColor blackColor].CGColor];
return cell;
}