在开发中我们有时候会需要区分页面的出现和消失是push进来的,还是pop回来的,或者是present的,还是dismiss的。
那么在页面即将出现或者即将消失的时候我们用以下代码进行区分即可:
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
if ([self isBeingDismissed] || [self isMovingFromParentViewController]) {
//pop 或者dismiss操作
} else {
// push 或者 present
}
}
网友评论