Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Safeguard against UITabBarController selecting a controller not in the tab bar #754

Closed
wants to merge 1 commit into from
Closed

Safeguard against UITabBarController selecting a controller not in the tab bar #754

wants to merge 1 commit into from

Conversation

kemenaran
Copy link
Contributor

Apple Docs states that only controllers in -[UITabBarController viewControllers] can be set as the -selectedViewController.

If for some reasons iOS messes up the view controllers hierarchy (it happens), setting an unknown view controller will fail (and present a blank screen). This fix avoids that.

…of the tab bar controllers

Apple Docs states that only controllers in -viewControllers can be set as the -selectedViewController.

If for some reasons iOS messes up the view controllers hierarchy (it happens), setting an unknown view controller will fail (and present a blank screen). This fix avoids that.
@tonklon
Copy link
Contributor

tonklon commented Jan 20, 2012

I don't like that fix. IMHO in a situation like this an Exception should be thrown (internal Inconsistency). But if the OS interferes here this is not an option. Do you have an example to reproduce the problem?

@kemenaran
Copy link
Contributor Author

I wrote an example when opening the Pull Request, and decided to keep it aside fro brevity's sake :) Anyway,I kept it somewhere, so here it is :

(see below, wrong button clicked.)

@kemenaran kemenaran closed this Jan 20, 2012
@kemenaran kemenaran reopened this Jan 20, 2012
@kemenaran
Copy link
Contributor Author

An example of messed up parentViewController hierarchy can be the following hierarchy of view controller :

UITabBarController
  -> UIViewController1
    -> UINavigationController(Modal)
      -> UIViewController2

In this case, on iOS < 5, the parentViewController of UINavigationController is the UITabBarController — instead of the expected UIViewController1. iOS >= 5 has the expected behavior though.

This causes Three20 to try to set UINavigationController as the selected controller of UITabBarController (when the TTNavigator loops over newly created controller to ensure they are actually visible, by sending -bringControllerToFront: messages recursively).

@aporat
Copy link
Contributor

aporat commented Jan 20, 2012

@kemenaran do you mind trying pulling #746 into your fork and test if that patch solves your issue (without your change)?
sounds like another parentViewController issue to me

@jamesgpearce
Copy link
Contributor

Facebook has not maintained or supported Three20 for some time, and we are closing its old and outstanding pull requests.

Many, many thanks for your support of the project. If you have any further questions, please don't hesitate to let me know.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants