2
제 애플리케이션의 경우 왼쪽에 메뉴로 UITableView가 있습니다. 테이블의 셀을 누르면 오른쪽의보기가 바뀝니다. "메뉴"테이블에 세관 셀이 있으며 이것을 선택하면 셀 이미지가 변경됩니다. 어떻게해야합니까?셀을 선택하면 이미지가 변경됩니다.
CODE :
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"MenuCell";
CRMMenuCell *cell = (CRMMenuCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (!cell){
NSArray * topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"CRMMenuCell" owner:nil options:nil];
for (id currentObjetc in topLevelObjects){
if ([currentObjetc isKindOfClass:[CRMMenuCell class]]){
cell = (CRMMenuCell *)currentObjetc;
break;
}
}
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
if (indexPath.row == 0)
{
cell.labelMenu.text = NSLocalizedString(@"calendarioKey", @"");
cell.imagenMenu.image = [UIImage imageNamed:@"calendario_gris"];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"MenuCell";
CRMMenuCell *cell = (CRMMenuCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (!cell){
NSArray * topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"CRMMenuCell" owner:nil options:nil];
for (id currentObjetc in topLevelObjects){
if ([currentObjetc isKindOfClass:[CRMMenuCell class]]){
cell = (CRMMenuCell *)currentObjetc;
break;
}
}
}
if (indexPath.row == 0)
{
cell.imagenMenu.image = [UIImage imageNamed:@"calendario_rojo"];
}
감사합니다.
을하지만 해결책을 발견하기 위해 내가 할 수 없습니다입니다 :
어떻게 이미지 구현에 따라 변경하지만 뭔가 같이해야한다 :
편집 : 다음 시도 나는 그 질문을 편집했다. – javiazo
네,하지만 문제는 내 셀이 맞춤 셀이고 내 속성 (이미지, 라벨 등)이 일반적인 UITableCellView에 없다는 것입니다. – javiazo
내 대답을 수정했습니다. 다른 셀을 사용하는 경우 이미지를 캐스팅하고 변경하기 전에 indexPath의 유효성을 검사해야 할 수도 있습니다. – user1567896