iPhone - 在 2 行代码之间等待异步任务完成
我有两行代码在弹出视图之前执行。 这两行正在滚动。 由于这 3 个动画,有很多东西用户看不到,或者说看不太清楚。
我不想使用回调来处理这个问题。 我只需要应用程序等待 0.5 秒,让视图弹出,并在两次滚动调用之间再等待 0.5 秒,让他看到发生了什么。
我怎样才能在不停止动画的情况下轻松做到这一点?
我尝试(很快)[NSThread sleepForTimeInterval:0.5];但它阻止了一切。当然。
I have two lines of code that are executed just before the pop of a view.
Those two lines are making some scrolling.
Because of those 3 animations, there are many things that the user don't see, or let's say don't see well.
I don't want to use callbacks to deal with this.
I just need the app to wait some 0,5 secs for the view to pop, and 0,5 secs more beetween the two scroll calls to let him see what is happening.
How may I do this easily without stopping the animations ?
I tried (quickly) [NSThread sleepForTimeInterval:0.5]; but it stops everything. Of course.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不能等待主 UI 线程中的动画完成,而不在第一行之后退出当前方法并对第二行使用回调。
如果您不喜欢回调,您的替代方法是将两行排队以便在后台线程中执行。
You can't wait for an animation to finish from the main UI thread without exiting from the current method after the first line and using a callback for the second line.
If you don't like callbacks, your alternative is to queue your two lines for execution in a background thread.