[iOS] UINavigationControllerからpopされるイベントを検出する
UIViewControllerのプロパティ「isMovingFromParentViewController 」を使う。
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
// Pop
if ([self isBeingDismissed] || [self isMovingFromParentViewController]) {
}
}
UIViewController.hに記述があります。
/*
These four methods can be used in a view controller's appearance callbacks to determine if it is being
presented, dismissed, or added or removed as a child view controller. For example, a view controller can
check if it is disappearing because it was dismissed or popped by asking itself in its viewWillDisappear:
method by checking the expression ([self isBeingDismissed] || [self isMovingFromParentViewController]).
*/