开发者

viewWillDisappear called when tab bar item selected view controller set

开发者 https://www.devze.com 2023-01-25 01:15 出处:网络
Here\'s the scenario: Window creates a tab bar controller and adds multiple tab bar item view controllers with a UINavigationController as the top view.

Here's the scenario:

  1. Window creates a tab bar controller and adds multiple tab bar item view controllers with a UINavigationController as the top view.
  2. viewWillAppear gets called on the first tab bar view.
  3. The user taps a control on the first tab view that pushes a view controller on the nav stack. viewWillDisappear gets called.
  4. After user interaction, the view is popped off the nav stack. viewWillAppear is called.
  5. User taps something which causes another view to be pushed on the nav stack. viewWillDisappear is called.
  6. User taps something which causes the code to set the selectedViewController on the tab bar cont开发者_如何学JAVAroller. viewWillDisappear gets called AGAIN on the main view for the first tab bar item.

Any ideas?


I ended up working around this by keeping a BOOL that would tell me if I need to perform the viewWillDisappear work or not. Ugly but it works. I was hoping there would be a better solution or that I was doing something that was obviously wrong.

0

精彩评论

暂无评论...
验证码 换一张
取 消