Search code examples
iosobjective-ciphoneuinavigationcontrollerviewdidload

Is there any way to avoid calling viewdidload method like tabbarcontroller?


I'm developing an application which will work based on maps. So once user opens MapViewController then I will load some data every 5 seconds.

I'm using navigation controller(Push view controller).

So every time when user goes to MapViewController viewdidload method calling. I don't want like that.

That's why I'm trying to avoid viewdidload method like tabbarcontroller.

Is there any way to achieve this?


Solution

  • Try this

    -(void)clickForPush{
        // declarre viewcontroller e.g 'saveRecipeVC' instance globally in interface
        if (!saveRecipeVC) {
            saveRecipeVC = [self.storyboard instantiateViewControllerWithIdentifier:SaveRecipeVCID];
        }
        [self.navigationController pushViewController:saveRecipeVC animated:YES];
    }