gle*_*enc 1 iphone animation uitableview
我正在尝试实现当用户点击我的一个tableview单元格时发生的动画.基本上,动画只是一个带有"+5"或"+1"等文字的小标签,然后在褪色的同时向上移动(基本上就像用户对它们进行评分时在视频游戏中出现的点).
在tableView:didSelectRowAtIndexPath:我的控制器的实现中,我正在做以下(为了简单起见,这里解释):
CGRect toastFrame = /* figure out the frame from the cell frame here */;
UILabel *toast = [[UILabel alloc] initWithFrame:toastFrame];
toast.text = [NSString stringWithFormat:@"+%d", 5];
toast.backgroundColor = [UIColor clearColor];
toast.userInteractionEnabled = NO; // hoped this would work but it doesn't
[tableView addSubview:toast];
[UIView
animateWithDuration:1.0
animations:^
{
toast.alpha = 0.0;
toast.transform = CGAffineTransformMakeTranslation( 0.0, -44.0 );
}
completion:^ (BOOL finished)
{
[toast removeFromSuperview];
}];
[toast release];
Run Code Online (Sandbox Code Playgroud)
烤面包很好看,看起来很棒.问题是,在动画完成之前,tableview会停止接收触摸事件.这意味着在点击tableview中的单元格后一秒钟,您无法点击tableview中的任何其他单元格.
有没有办法阻止这种情况发生,并允许用户继续与tableview交互,好像动画根本没有发生?
在此先感谢您的帮助.
另一个选择可能是使用animateWithDuration:delay:options:animations:completion:(未经测试,从我的头顶)
看一下options参数和可能的标志,由UIViewAnimationOptions.定义.包括一个叫做的旗帜UIViewAnimationOptionAllowUserInteraction.这可能是一个解决方案,也许你应该尝试一下!
| 归档时间: |
|
| 查看次数: |
964 次 |
| 最近记录: |