Я называю didSelectRowAtIndexPath:
как и в viewDidAppear
`didDeselectRowAtIndexPath:` не вызывается после вызова `didSelectRowAtIndexPath:`
-(void)viewDidAppear:(BOOL)animated {
[self tableView:self.tableView didSelectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
}
Это didSelectRow
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = (UITableViewCell*)[tableView cellForRowAtIndexPath:indexPath];
[UIView animateWithDuration:0.4 animations:^{
cell.contentView.backgroundColor = [UIColor blackColor];
cell.textLabel.textColor = [UIColor whiteColor];
}];
[UIView animateWithDuration:0.4 animations:^{
UITableViewCell *cell = (UITableViewCell*)[tableView cellForRowAtIndexPath:indexPath];
cell.contentView.backgroundColor = [UIColor blackColor];
cell.textLabel.textColor = [UIColor whiteColor];
cell.textLabel.transform = CGAffineTransformMakeScale(1.1f, 1.1f);
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.4 animations:^{
cell.textLabel.transform = CGAffineTransformIdentity;
}];
}];
}
Он работает нормально, но когда я выбираю новая ячейка, первая ячейка, выбранная в вызове viewDidAppear
на didSelectRow
, не вызывает didDeselectRowAtIndexPath:
, она остается черной, а анимация ниже не выполняется, когда выбрана новая ячейка. Проблема заключается в том, что первая ячейка, выбранная в вызове viewDidAppear
, остается выбранной до ее повторного выбора. Кажется, проблема в том, что indexPath не передается без прикосновения.
-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = (UITableViewCell*)[tableView cellForRowAtIndexPath:indexPath];
[UIView animateWithDuration:0.4 animations:^{
cell.contentView.backgroundColor = [UIColor whiteColor];
cell.textLabel.textColor = [UIColor blackColor];
}];
}
я поставил его в 'viewDidLoad' должен быть хорошо – noobsmcgoobs