UIViewcontroller not visible in the uinavigationcontroller stack

160 views Asked by At

To the window i am adding a uinavigation controller as the rootviewcontroller of the window.Say first view controller is the root viewcontroller.In this first viewcontroller i am firing an nstimer with repeat interval of 15 sec to call an api and update the UI.I am properly invalidating this fired timer in viewwilldisappear.After some time,say after 150 sec i am pushing to another viewcontroller say secondviewcontroller.

Firstviewcontroller and secondviewcontroller has back buttons to pop view accordingly. In the secondviewcontroller's view did load i have logged the class name.While the navigation controller has pushed from the firstviewcontroller to secondviewcontroller i see the log.But if i click the back button of the secondviewcontroller ,the log is [firstviewcontroller backbutton] and first viewcontroller events are running.ie secondviewcontroller is not visible and then the screen goes black.

My project is arc fied.

I know this might be some stupid question,but really my head is burning!.

1

There are 1 answers

0
venky On

I faced same like this issue before. I hope you are running NSTimer in NSRunLoop. Please remove the piece of code.

 NSRunLoop *runLoop = [NSRunLoop mainRunLoop];
   [runLoop addTimer:timer forMode:NSDefaultRunLoopMode];
   [runLoop run];