Теоретически следующий код должен анимировать ячейку просмотра таблицы справа и принести темный «вид» на своем месте.Просмотр не выглядит должным образом
CGPoint location = [gesture locationInView:tableView];
NSIndexPath *swipedIndexPath = [tableView indexPathForRowAtPoint:location];
UITableViewCell *swipedCell = [tableView cellForRowAtIndexPath:swipedIndexPath];
//code to create view
UIView *sideView;
sideView.backgroundColor = [UIColor lightGrayColor];
//set the side view frame to the same as the cell
sideView.frame = swipedCell.frame;
//add it to the tableview
[tableView addSubview:sideView];
[UIView animateWithDuration:1
animations:^{
sideView.frame = CGRectMake(0, swipedCell.frame.origin.y, swipedCell.frame.size.width, swipedCell.frame.size.height);
// While simultaneously moving the cell's frame offscreen
// The net effect is that the side swipe view is pushing the cell offscreen
swipedCell.frame = CGRectMake(swipedCell.frame.size.width, swipedCell.frame.origin.y, swipedCell.frame.size.width, swipedCell.frame.size.height); //move cell off
}];
Однако только ячейка перемещается с экрана. В его месте нет серого вида.
Есть ли уступ, который мне не хватает? Что не так с этим кодом?
Видео примера here
я должен был сделать UIView * вид = [[UIView Alloc] инициализации]; потому что я не хотел устанавливать кадр, пока анимация не произошла. Но это исправило мою проблему. –
Получил меня на верном пути хотя бы. –
Нет проблем. Иногда просто берет второй набор глаз, чтобы заметить глупые проблемы, как только вы слишком долго смотрели на что-то. – Idles