UINavigationController crash because of pushing and poping UIViewControllers

前端 未结 2 1096
时光说笑
时光说笑 2020-12-12 04:48

The issue: I have a UINavigationController as as subview of UIWindow, a rootViewController class and a custom MyViewController class. The following steps wi

相关标签:
2条回答
  • 2020-12-12 05:44

    It might be related to both instances of your view controller using the same statically-allocated variable.

    In other words, both myViewController_1stInstance and myViewController_2ndInstance are using the same variable1 location in memory and overwriting one another.

    Variables declared inside of the curly braces after your @interface definition have a memory location allocated by the runtime for each instance of the class (every time you call [<ClassName> alloc]. Variables declared in the global scope (that is, outside of any functions or class declarations) are just that: global. That means that the variable can only hold one value per running copy of your application.

    There are no truly private variables in Objective-C, but you can hide them from other instances at compile time as described here.

    0 讨论(0)
  • 2020-12-12 05:46

    A bit of a late reaction, but I've seen this problem before. Don't push two viewControllers animated at the same time. Push the first one without animation and push the second one with animation. UINavigationController can't handle two animations at the same time.

    0 讨论(0)
提交回复
热议问题