I have been experimenting a little with using UITableView's deselectRowAtIndexPath: to help the user know which row was being viewed when returning to the tableview.
我一直在尝试使用UITableView的deselectRowAtIndexPath:来帮助用户知道返回tableview时正在查看哪一行。
I've noticed that I can place this in viewWillAppear and viewDidAppear with slightly different results. The first begins the animation as the popped view slides out, while the latter only begins the animation once the popped view is completely gone. As a result, the latter feels more 'pronounced', I guess (more of the animation occurs with the row fully on screen - in fact all of it).
我注意到我可以将它放在viewWillAppear和viewDidAppear中,结果略有不同。第一个在弹出视图滑出时开始动画,而后者仅在弹出视图完全消失后才开始动画。结果,后者感觉更“明显”,我想(更多的动画发生在屏幕上的行完全 - 实际上所有这一切)。
Aesthetically, this is a useful distinction, since I get more control over the user experience. However, some questions:
在美学上,这是一个有用的区别,因为我可以更好地控制用户体验。但是,有些问题:
- Is there any technical reason I should use one over the other?
- 是否有任何技术原因我应该使用一个而不是另一个?
- Looking carefully at some of Apples applications I think they are animating in viewWillAppear. Can anyone confirm?
- 仔细查看一些Apples应用程序,我认为它们在viewWillAppear中是动画的。谁能确认一下?
- Is there a risk using viewWillAppear that the animation will complete offscreen (maybe due to some laggy processing etc in the popped view controller)? Or does it only fire at the beginning of the transition from the popped view?
- 使用viewWillAppear是否存在动画将在屏幕外完成的风险(可能是由于弹出视图控制器中的某些滞后处理等)?或者它只是在弹出视图转换开始时触发?
1 个解决方案
#1
0
1) If your code is dependent on the view being fully loaded, viewDidAppear is better, but in this case I don't think it makes a technical difference.
1)如果您的代码依赖于完全加载的视图,则viewDidAppear更好,但在这种情况下,我认为它不会产生技术差异。
2) I don't think any of us work at Apple...
2)我不认为我们任何人在Apple工作......
3) viewWillAppear by definition is called just before the view begins to show itself. If your animation takes longer than the view takes to appear then yes, it will be offscreen. Otherwise it will be (Animation length - (minus) Time for view to appear)
3)viewWillAppear按定义在视图开始显示之前调用。如果您的动画花费的时间比视图显示的时间长,那么它将在屏幕外显示。否则它将是(动画长度 - (减去)视图出现的时间)
#1
0
1) If your code is dependent on the view being fully loaded, viewDidAppear is better, but in this case I don't think it makes a technical difference.
1)如果您的代码依赖于完全加载的视图,则viewDidAppear更好,但在这种情况下,我认为它不会产生技术差异。
2) I don't think any of us work at Apple...
2)我不认为我们任何人在Apple工作......
3) viewWillAppear by definition is called just before the view begins to show itself. If your animation takes longer than the view takes to appear then yes, it will be offscreen. Otherwise it will be (Animation length - (minus) Time for view to appear)
3)viewWillAppear按定义在视图开始显示之前调用。如果您的动画花费的时间比视图显示的时间长,那么它将在屏幕外显示。否则它将是(动画长度 - (减去)视图出现的时间)