“以编程方式”;闪烁;UITableViewCell将背景色设置为白色
我在我的“以编程方式”;闪烁;UITableViewCell将背景色设置为白色,uitableview,ios7,uigesturerecognizer,Uitableview,Ios7,Uigesturerecognizer,我在我的UICollectionView中设置了ui长按手势识别器,它调用 - (void)longPress:(UILongPressGestureRecognizer *)gesture { if (gesture.state == UIGestureRecognizerStateBegan) { CGPoint point = [gesture locationInView:self.collectionView]; NSIndexPath *ind
UICollectionView
中设置了ui长按手势识别器
,它调用
- (void)longPress:(UILongPressGestureRecognizer *)gesture {
if (gesture.state == UIGestureRecognizerStateBegan) {
CGPoint point = [gesture locationInView:self.collectionView];
NSIndexPath *indexPath = [self.collectionView indexPathForItemAtPoint:point];
if (indexPath) {
self.manager.currentLongPressIndex = indexPath.row;
[self showPopover];
}
}
}
方法中显示的uipover
具有UITableView
。我的目标是“闪存”(选择然后取消选择UITableViewCell
)并滚动显示它。我就是这样做的:
- (void)viewDidLoad {
[super viewDidLoad];
// get the current index path
NSIndexPath *path = [NSIndexPath indexPathForRow:self.manager.currentLongPressIndex inSection:0];
// set flag
self.cellIsFlashing = YES;
// select cell
[self.tableView selectRowAtIndexPath:path animated:YES scrollPosition:UITableViewScrollPositionMiddle];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (self.cellIsFlashing == NO) {
[self.viewController.collectionView scrollToItemAtIndexPath:indexPath atScrollPosition:UICollectionViewScrollPositionTop animated:YES];
} else {
self.cellIsFlashing = NO;
}
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
}
这是可行的,但选定单元格的背景色变为白色,闪光效果看起来不太好,看起来根本没有设置动画
尝试延迟取消选择过程:
-(void)deselectRow:(NSIndexPath *)indexPath {
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
... // your code here
// call the deselect method with 0.3 second delay
[self performSelector:@selector(deselectRow:) withObject:indexPath afterDelay:0.3f];
}
不确定这是否可行,但值得一试。通过将单元格选择代码从
viewDidLoad
更改为ViewDidDisplay:animated: