내 확인란을 변경하지 않은 행을 선택할 때 테이블보기에 사용자 지정 확인란이 만들어졌습니다. 나에게 도움을 주시기 바랍니다표보기 셀에 확인란을 추가하는 방법은 무엇입니까?
내 코드 : 사전에
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
@try {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
checkButton = [UIButton buttonWithType:UIButtonTypeCustom];
[checkButton setFrame:CGRectMake(5, 5, 20, 20)];
[cell addSubview:checkButton];
pLblCabType = [[UILabel alloc]initWithFrame:CGRectMake(30, 5, 200, 20)];
[cell addSubview:pLblCabType];
pLblTariff = [[UILabel alloc]initWithFrame:CGRectMake(240, 5, 80, 20)];
[cell addSubview:pLblTariff];
}
[checkButton setImage:[UIImage imageNamed:[pArrImgBullet objectAtIndex:indexPath.row]] forState:UIControlStateNormal];
pLblCabType.text = @"Arul";
pLblTariff.text = @"Rs.1250";
return cell;
}
@catch (NSException *exception) {
NSLog(@"Exception Error is %@",exception);
}
@finally {
}
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
@try {
[checkButton setImage:[UIImage imageNamed:@"Bullet_Select.png"] forState:UIControlStateSelected];
[pArrImgBullet replaceObjectAtIndex:indexPath.row withObject:@"Bullet_Select.png"];
}
}
@catch (NSException *exception) {
NSLog(@"Exception Error is %@",exception);
}
@finally {
}
}
감사합니다, S.Arul
여기서'checkButton''pLblCabType''pLblTariff'를 정의하고 있습니까? 대기열에서 제외 된 다음 셀 뷰에서 하위 뷰를 제거하는 이유는 무엇입니까? –
셀 체크에 PLblCabType, PlblTariff 체크 버튼을 생성 중입니다. –
UITableViewCell의 하위 클래스를 만들었습니까? –