简体   繁体   中英

UIViewcontroller not visible in the uinavigationcontroller stack

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!.

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];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM