iOS: UIButton background image getting removed for button in custom uitableviewcell on scroll
我的自定义表格视图单元格中有一个 uibutton,它为不同单元格的按钮提供不同的背景图像。一旦我开始滚动,超出范围的随机单元格就会删除它们的背景图像。我有两个带有两个背景图像的按钮,但它总是为其中一个做

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
– (UITableViewCell *)tableView :(UITableView *)tableView
cellForRowAtIndexPath :(NSIndexPath *)indexPath
{
…
…
PlayerTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier :@ “playerCell”];
if(cell == nil ) {
NSArray* topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@“PlayerTableViewCell” owner:self options:nil];
for (id currentObject in topLevelObjects) {
if ([currentObject isKindOfClass:[PlayerTableViewCell class]])
cell = (PlayerTableViewCell *)currentObject;
}
}
numberImage = [self getUserImage:[self._collectionsNewGame[indexPath.row –1] objectForKey:@“hostBirthday”] isSign:false];
signImage =[self getUserImage:[self._collectionsNewGame[indexPath.row –1] objectForKey:@“hostBirthday”] isSign:true];
cell.numberButton setBackgroundImage:[UIImage imageNamed:numberImage] forState:UIControlStateNormal];
[cell.signButton setBackgroundImage:[UIImage imageNamed:signImage] forState:UIControlStateNormal];
…
…
}
|
请帮忙
- 我看不到您在代码中设置按钮的位置。什么是 cell.numberButton,什么是 cell.signButton?
使用
1
|
[tableView dequeueReusableCellWithReuseIdentifier:@“playerCell” forIndexPath:indexPath];
|
而不是
1
|
[tableView dequeueReusableCellWithIdentifier:@“playerCell”];
|
- 那个解决的图标没有出现,但它显示在不同的地方?
-
我已经开始缓存单元格来解决这个问题。我会将此标记为正确答案
-
谢谢。一切顺利 !!
来源:https://www.codenong.com/31032344/
微信公众号
手机浏览(小程序)
Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(): Failed to enable crypto in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_9914.jpg): failed to open stream: operation failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57