iPhone:viewWillAppear仅在从其他视图返回时 [英] iPhone: viewWillAppear only when coming back from other views

查看:125
本文介绍了iPhone:viewWillAppear仅在从其他视图返回时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

viewWillAppear

我想在从其他视图返回时选择(突出显示)和淡出单元格。

I want to select(highlight) and fade-out a cell only when coming back from other views.

是否有委托方法来执行此操作?

Is there a delegate method to do this?

我正在使用UINavigationViewController。

I'm using UINavigationViewController.

推荐答案

如果您的目标是iOS 5,那么你可以使用 [self isBeingPresented] [self isBeingDismissed] 来确定是否正在添加或删除视图控制器导航控制器。

If you are targeting iOS 5, you can use [self isBeingPresented] and [self isBeingDismissed] to determine if the view controller is being added or removed from the nav controller.

我也怀疑你可以改进选择/取消选择表视图中的单元格的逻辑,这样无论是否视图控制器即将到来。

I'm also suspecting that you could improve the logic of when you select/deselect the cell in your table view such that it doesn't matter whether the view controller is coming or going.

通常的做法是:当有人在视图控制器A的表视图中选择一行时,它会被选中/突出显示然后你推一个新的视图控制器B.当你查看c ontroller B被解除,你动画取消选择 viewDidAppear 中的表视图行(所以用户可以看到它淡出)在视图控制器A中。你不会担心视图控制器A是刚刚出现还是重新出现,因为在适当的情况下只会有一个选定的表视图单元格。

The usual way to do it is this: when someone selects a row in the table view in view controller A, it gets selected/highlighted and you push a new view controller B. When view controller B is dismissed, you animate the deselection of the table view row in viewDidAppear (so the user can see it fading out) in view controller A. You wouldn't worry about whether view controller A has just appeared or is re-appearing, because there would only be a selected table view cell in the appropriate case.

这篇关于iPhone:viewWillAppear仅在从其他视图返回时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆