Can i know in viewWillAppear that it was called after navigationController pop (back button)?

后端 未结 3 2016
感动是毒
感动是毒 2021-02-06 23:58

Say I have UIViewController A and B. User navigates from A to B with a push segue. Than user presses back button and comes to A.

Now viewWillAppear

3条回答
  •  时光取名叫无心
    2021-02-07 00:59

    Add a BOOL property to UIViewController A:

    @property (nonatomic) BOOL alreadyAppeared;
    

    Then in your viewWillAppear: method, add:

    if (!self.alreadyAppeared) {
        self.alreadyAppeared = YES;
        // Do here the stuff you wanted to do on first appear
    }
    

提交回复
热议问题