2013-11-02 7 views
0

У меня есть ячейка UITableView с четырьмя строками, которые пользователи могут щелкнуть, и она выводит их на веб-страницу. Проблема в том, что пользователи нажимают на ячейку, она не становится синей, показывая, что пользователь был нажат. Ячейки работают нормально, когда при нажатии вы переходите к делегату веб-страницы. Но я хотел бы, чтобы клетка поменяла цвет при касании, чтобы они знали, в какую ячейку они нажали. Ниже приведен код:iOS UItableviewcell не имеет анимации при прослушивании

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 
// Return the number of sections. 
return 1; 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section  { 
// Return the number of rows in the section. 
return 4; 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
static NSString *CellIdentifier = @"Cell"; 
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

if (cell == nil) { 
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier]; 
} 

// Configure the cell... 
cell.detailTextLabel.textColor  = [UIColor grayColor]; 
cell.textLabel.font=[UIFont fontWithName:@"Helvetica" size:19]; 
cell.detailTextLabel.lineBreakMode = UILineBreakModeWordWrap; 

cellHasStoreLink = YES; 

ответ

1

Вы должны либо это:

cell.selectionStyle = UITableViewCellSelectionStyleGray; 

или что-то подобное раньше return cell:

UIView *bgColorView = [[UIView alloc] init]; 
[bgColorView setBackgroundColor:[UIColor redColor]]; 
[cell setSelectedBackgroundView:bgColorView]; 
[bgColorView release]; 
+0

Ни один из тех, кто работал. Я думаю, что проблема связана с ячейками, имеющими текст в них, который поступает из json-файла. –

+0

Можете ли вы вставить весь код для cellForRowAtIndexPath? –

+0

- (UITableViewCell *) tableView: (UITableView *) tableView cellForRowAtIndexPath: (NSIndexPath *) indexPath { static NSString * CellIdentifier = @ "Cell"; UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier: CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle: UITableViewCellStyleValue1 reuseIdentifier: CellIdentifier]; } // Конфигурирование ячейки ... cell.detailTextLabel.textColor = [UIColor grayColor]; cell.textLabel.font = [UIFont fontWithName: @ "Helvetica" size: 19]; –

Смежные вопросы