2011-08-08 6 views
1

파란색으로 바뀌는 셀 텍스트를 클릭하면 다른 셀을 클릭 할 때까지 파란색으로 변합니다. UITableView에 세부 텍스트 레이블을 사용하고 있습니다. . 다음과 같은 사용자가UITableView 셀 색상이 사라지지 않습니다

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; 
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone]; 
    .. your view changing code 
} 

답변

2

cellForRowAtIndex에서

[cell setSelectionStyle:UITableViewCellSelectionStyleNone]; 

클래스에이 코드를 추가 :

- (void)viewWillAppear:(BOOL)animated 
{ 
    // this UIViewController is about to re-appear, make sure we remove the current selection in our table view 
    NSIndexPath *tableSelection = [self.tableView indexPathForSelectedRow]; 
    [self.tableView deselectRowAtIndexPath:tableSelection animated:NO]; 
} 
5

는 대리인의 didSelectRowAtIndexPath: 방법에 행을 선택 해제

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    [tableView deselectRowAtIndexPath:indexPath animated:YES]; 
} 

그리고

+0

- (무효)있는 tableView : (jQuery과 *)있는 tableView didSelectRowAtIndexPath : (NSIndexPath *) indexPath { \t \t CategoriesList * dvController = [[CategoriesList alloc] initWithNibName : @ "CategoriesList"번들 : nil]; \t // 선택한 개체를 새보기 컨트롤러에 전달합니다. \t //dvController.description = description; \t //dvController.title=title; \t //dvController.descriptionImage=descriptionImage; \t [self.navigationController pushViewController : dvController animated : YES]; \t [dvController release]; \t } – ali

+0

코드에서 편집 중이지만 제대로 작동하지 않습니다. – ali

+0

@ali "not working"은 잘못된 설명입니다. 정확히 작동하지 않는 것은 무엇입니까? – Vladimir

0

그냥 선택 스타일을 제거 :

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell == nil) { 
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease]; 
    UIImageView* img = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"cell1.png"]]; 
    [cell setBackgroundView:img]; 
    [img release]; 
} 
+0

내가이 일을 잘하고 하나의 컨트롤러와 함께하지만 두 번째보기에 거기 가서 clicl 뒤로 버튼을 테이블보기를 이동하는 예외를 제공합니다 – ali

0

당신이해야 할 행을 선택하면

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 
    [tableView deselectRowAtIndexPath:indexPath animated:YES]; 
    ... 
}