【iOS】判断viewcontroller 来源(展示出来)的4个方法

本文介绍了在iOS中判断UIViewController出现原因的四个方法:isMovingFromParentViewController、isMovingToParentViewController、isBeingPresented和isBeingDismissed。这些方法适用于容器与内容视图控制器之间的交互,如导航控制器的push和pop,以及present和dismiss操作。通过在对应的方法中调用这些API,可以了解视图控制器的显示或消失是由添加到容器、移除、呈现还是被关闭所引起。
摘要由CSDN通过智能技术生成
isMovingFromParentViewController / isMovingToParentViewController :适应于container 和 content viewcontroller 之间。例如:addChildViewController方法,navigationController 中的push 和pop。

isBeingPresented / isBeingDismissed :适应于present 和 presented viewcontroller 之间。presentViewController: animated: completion方法。

【官方资料】
Determining Why a View’s Appearance Changed

Occasionally, it can be useful to know why a view is appearing or disappearing. For example, you might want to know whether a view appeared because it was just added to a container or whether it appeared because some other content that obscured it was removed. This particular example often appears when using navigation controllers; your content controller’s view may appear because the view controller was just pushed onto the navigation stack or it might appear because controllers previously above it were popped from the stack.

The UIViewController
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值