0
내가 셀을 클릭하면 색상이 바뀌어야하고 색상이 해당 셀에 남아 있어야합니다. 여기에서 내가 성공했습니다.하지만 테이블이 새로 고칠 때 다음 셀 배경 색상 내가 잘못 어디에 사라 당신이 원하는 경우 코드ipad에서 클릭 할 때 셀 배경색 또는 이미지를 변경하는 방법
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
//here i create view with color for cell when cell is click this view should display as background i am write or wrong by doing this please help me here why my view is disappear when my tableview is refresh then this view is disapper from cell i want to stay that place till user not click other cell&mt tableview is grouped tableview.
UIView *v = [[[UIView alloc] init] autorelease];
v.layer.cornerRadius =6.0f;
v.backgroundColor = [UIColor darkGrayColor];
cell.selectedBackgroundView = v;
}
return cell;
}
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row == 0 || indexPath.row%1 == 0) {
UIColor *altCellColor = [UIColor colorWithWhite:0.2 alpha:0.1];
cell.backgroundColor = altCellColor;
}
}
안녕하세요 친구 어디서이 코드를 사용하려면 셀렉션 방법을했는데 셀이 선택되면 충돌이 발생합니다 – Rocky
indexPath를 didSelect 메서드에 저장하고 cellForRowAtIndexPath.and에서 위의 메서드를 호출해야합니다. 충돌 로그를 표시 할 수 있습니까? –
ipad에서 spliteview 응용 프로그램을 만들고 있습니다. 왼쪽보기는 tableview 및 오른쪽보기입니다. 선택한 데이터를 새로 추가 할 때 모든 데이터 항목이 표시됩니다. 선택한 셀 색이 새로 고침되고 셀에서 사라집니다. – Rocky