내 tableview에서 그림을 변경하려고합니다. 내 TableView
을 새로 고치기 위해 [myTableView reloadData];
을 다른 방법으로 사용하고 있습니다. 그리고 나는 tableview의 다른 요소가 상쾌하지만 이미지가 그대로 유지되는 것을 볼 수 있습니다. 나는 무엇을 놓치고 있습니까?UITableView 내에서 그림을 새로 고칠 수 없습니다.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
UILabel *lblName;
UIImageView *checkMark = [[UIImageView alloc] initWithFrame:CGRectMake(230, 0, 30, 50)];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
UIView *backgroundView = [[UIView alloc] initWithFrame:CGRectMake(10, 1, 260, 70)];
backgroundView.backgroundColor = UIColorFromRGB(0x000000, 0.3);
backgroundView.userInteractionEnabled = YES;
checkMark.image = [UIImage imageNamed:@"V.png"];
checkMark.contentMode = UIViewContentModeCenter;
checkMark.backgroundColor = [UIColor clearColor];
[backgroundView addSubview:checkMark];
[checkMark release];
[cell.contentView addSubview:backgroundView];
[backgroundView release];
}
if (something)
{
checkMark.image = [UIImage imageNamed:@"halfleft.png"];
NSLog(@"something was done");
}
return cell;
}
전 '의 경우'} '마지막 (무언가) '를 바로 아래로 이동해야합니다. [= [[UITableViewCell alloc] initWithStyle : UITableViewCellStyleDefault reuseIdentifier : CellIdentifier] autorelease];' – Groot
왜 그런가요? 셀이 nil이 아니라면 하위 뷰를 계속 추가하고 싶지 않습니다. – Segev
하지만 동일한 셀 rigth에 새로운 이미지가 나타나야합니까? 따라서 셀이 없으면 그냥 셀만 만들면됩니다. 다른 모든 것들은 바깥쪽에 있어야합니다 (셀 == nil). – Piyuesh