Note that there are some explanatory texts on larger screens.

plurals
  1. POsetRootViewController: doesn't work as expected after setViewControllers: have been called
    primarykey
    data
    text
    <p>I created a view controller programmatically and set it as a root controller. All worked perfect as it was expected:</p> <pre><code>self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; CustomViewController *vc = [[CustomViewController alloc] init]; [[self window] setRootViewController:vc]; self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; return YES; </code></pre> <p>Then I added an UITabBarViewController, set its 'viewControllers' property to point to (an array to) the main viewController 'vc'.</p> <pre><code>self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; CustomViewController *vc = [[CustomViewController alloc] init]; UITabBarController *tbc = [[UITabBarController alloc] init]; NSArray *controllers = @[vc]; [tbc setViewControllers:controllers]; [[self window] setRootViewController:vc]; self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; return YES; </code></pre> <p>and the view stoped to show at the screen upon launch, also there is warning about the root view controller wasn't set. After adding the string below the view of 'vc' controller is finally loaded, but there is a blank line at the bottom of the screen, as if the UIBarController modified [[UIMainScreen bounds].</p> <pre><code>[[self window] addSubview:vc.view]; </code></pre> <p>I'm new to iOS development, and I'm a bit confused. It seems I don't understand some very fundamental things about the view controllers hierarchy, but after reading the "View Controller Programming Guide" by Apple, I still don't understand where am I wrong.</p> <p>The setRootViewController: method should auto assign the _view of argument view controller as default view of the window, but it doesn't happen if the named view controller was already previously pointed by viewControllers property of UITabBarViewController. Though I checked the debugger and found that 'vc' object isn't changed after setViewControllers: method is called.</p> <p>Could you please explain me what is going on or point me to a documentation I should read?</p> <p>UPDATE: I'm not going to insert the 'vc' controller into the 'tbc' controller. What I'd like is to display the 'vc' view fullscreen, as it would normally displayed without the code about 'tbc'. From my point of view, adding another view (tbc in my case) should NOT affect this behaviour.</p> <p>Of course, that's pretty useless from practical point of view, but I'd like to know what's going on under the hood.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload