Why isn't viewWillDisappear or viewDidAppear being called?

前端 未结 4 699
醉话见心
醉话见心 2020-12-31 21:59

I have a UINavigationController with a UITableView as my main menu. User clicks on a cell and a new view is pushed on the stack. In one case I push

4条回答
  •  -上瘾入骨i
    2020-12-31 22:31

    Yes Its true

    you can do this by first write this code in

    - (void)viewDidLoad {
        self.navigationController.delegate = self;  
    }
    

    And then write the code which you want to write in viewWillAppear

    - (void)navigationController:(UINavigationController  *)navigationController didShowViewController:(UIViewController  *)viewController animated:(BOOL)animated {
    
        if ([viewController isKindOfClass:[self class]]) {
            //write your code here
        } 
    }
    

提交回复
热议问题