Determine if view that appears was pushed or came from back button in navigation bar

前端 未结 3 980
天命终不由人
天命终不由人 2021-02-20 05:55

Is there a way to tell if a new controller came from a navigation back button or was pushed onto the stack? Id like to reload data only for pushing on the navigation stack, not

3条回答
  •  伪装坚强ぢ
    2021-02-20 06:33

    As of iOS 5.0 you can do this:

    - (void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear:animated];
    
        if (self.isBeingPresented || self.isMovingToParentViewController) {
            // "self" is being shown for the 1st time, not because of a "back" button.
        }
    }
    

提交回复
热议问题