rootViewController property does not work on iOS 5 project with xcode 4.2

Hi I just started experimenting on iOS 5. I created a project without storyboard and trying to add views programmatically (no use of interface builder at all). I have following code but rootViewController property of the window does not seem to work. I did NSLog on self.tabController and it shows me value(not null) but on the other side when after self.window.rootViewController = self.tabController, i output self.window.rootViewController it gives me null in console.

I have been struggling with this issue for a long time now. Any help would be appreciated.

Following is my didFinishLaunching method:

self.dataSource = [[[ADJWebDataSource alloc] init] autorelease]; ADJBrowseListingsViewController *browseListingsVC = [[ADJBrowseListingsViewController alloc] init]; ADJSecondViewController *secondVC = [[ADJSecondViewController alloc] init]; tabBarController = [[UITabBarController alloc] init]; tabBarController.view.frame = CGRectMake(0, 0, 320, 460); navController = [[UINavigationController alloc] initWithRootViewController:browseListingsVC]; NSMutableArray* viewControllers = [[NSMutableArray alloc] initWithCapacity:2]; [viewControllers addObject:browseListingsVC]; [viewControllers addObject:secondVC]; [navController release]; [browseListingsVC release]; [secondVC release]; tabBarController.viewControllers = viewControllers; [viewControllers release]; browseListingsVC.dataSource = self.dataSource; NSLog(@"controller %@", self.tabBarController); self.window.rootViewController = self.tabBarController; NSLog(@"controller1 %@", self.window.rootViewController); [self.window makeKeyAndVisible]; return YES;

Thanks Vik

-------------Problems Reply------------

When you are using story board, why are you still creating objects for view controllers? You can directly prepare the flow of your views in story board, add necessary segues etc. If your view controller is floating (without any segues), you have to use the method "instantiateViewControllerWithIdentifier" in story board class.

For a view controller if you want to add navigation in story board, select the view controller, go to menu "Editor"->"Embed in" and select navigation controller. It will add navigation controller to your view controller.

Figured it out with the help of Firoze. Actually, I had to allocate and initialize self.window programmatically. I was confused as I never had to do that in iOS 4 or earlier. But then I just realized prior to iOS5, every project has a MainWindow.xib which had self.window allocated and initialized, now if I am not using storyboard in iOS5, there is no .xib file, I needed to allocate and initialize it myself in the code

Category:iphone Views:0 Time:2011-11-04

Related post

  • How to add core data to my exisiting iOS project in xcode? 2011-05-11

    Possible Duplicate: Adding Core Data to existing iPhone project In my existing iOS project in xcode, there is no core data. I need to add core data back to the project, how to do that ? Thanks. --------------Solutions------------- see this Adding cor

  • Added Mac target to iOS project in Xcode, now 'Error Starting Executable File' 2011-05-19

    I've decided to make a Mac OSX port of my iOS app, so based on a number of suggestions I've received I've simply added a new Cocoa target to my iOS project, and set up a series of 'libraries' (which encapsulate the core business logic of my app) whic

  • Linking a static library to an iOS project in XCode 4 2011-05-25

    I have a project (AQGridView) that compiles to a static library, but I can't seem to add it to my project. Dragging in the project to my project creates a workspace, and if I try to link the libAQGridView.a file from the DerivedData directory it does

  • Include issue: header file not found in iOS project in Xcode 4 2012-02-16

    Consider my setup looks like this: XCode 4 iphone/ipad project ObjC .m file that includes a new header file, this header is reported as "file not found" ObjC .m file is located in root folder of the project new header file is also located in root fol

  • New iOS project, free hosted repository: Xcode 4 or Xcode 3.2? 2011-01-25

    I wonder whether I should start development of a new iOS project in Xcode 4 or 3.2 - on one hand, I know 3.2 (a little), there is lots of info about it out there, and it's stable and proven. On the other hand, Xcode 4 brings some improvements as well

  • Using static .lib (c) in iOS Project - Expected '=',',',';','asm' or 'attribute' before 2010-11-10

    I am trying to use static libraries that are written in c in an iOS Project. I included the .lib files and the .h into the iOS project. When I try to import the header files in one of my objective-C classes I get a lot of Expected '=',',',';','asm' o

  • How can I change the name of my iOS project? 2010-12-06

    How can I change a name of my project in the Xcode? --------------Solutions------------- I'm not sure exactly what you are asking, so I've given two parts to my answer. To change the display name of your project, (under the icon on the home screen) y

  • Why is viewDidLoad called twice when the rootViewController property of UIWindow is set? 2011-03-28

    There were already a couple of similar questions, but it wasn’t exactly the same as in my case. Just start a new view based project, add viewDidLoad and awakeFromNib with NSLog statements and do the following changes in MainWindow.xib: Remove the vie

  • How to implement CHCircularBuffer in iOS project? 2011-06-21

    for my game iOS project I need a ring buffer. It should work similar to a queue where elements go out and go in but the total amount of elements in the buffer should stay the same. I implemented the ring buffer successfully using java but I am not so

  • UIWindow's rootViewController Property 2011-10-20

    I noticed that if I create a viewcontroller and add its view as a subview of window (a UIWindow), the display is incorrect. For some reason, my viewcontroller is displayed 40 points to the top (the same height as the status bar). If I set the view co

  • No User Interface file created with iOS Project 2011-11-23

    I am getting started with iOS programming, and created a new project in XCode 4.2.1. However, I do not see .xib file in my project as expected. I tried added a new .xib file and build interface on it, but when I run my program, I see a blank white sc

  • How to group toolbar items in iOS project? 2012-01-16

    in many iOS projects you can see toolbar items that are grouped like this As you can see the arrows are grouped. Any idea how to achieve this by code? --------------Solutions------------- Actually you can put anything (any View) in UIToolbar. Every U

  • How to run and deploy Xcode 4.2 project in Xcode 3.2 and iOS 4.2 device 2012-01-20

    Currently i am working on Xcode 4.2 with iOS 5 sdk. I have created the project with core data framework. I have designed the screens and deployed in iOS 5 devices. I want to run my project in Xcode 3.2 because i want to deploy the app in iOS 4.2 devi

  • Diagnosing Bad OutputPaths: "The OutputPath property is not set for this project" (in the wonderful world of web deployment projects) 2008-10-01

    Starting with the error: Error 81 The OutputPath property is not set for this project. Please check to make sure that you have specified a valid Configuration/Platform combination. Configuration='Staging' Platform='AnyCPU' C:\WINDOWS\Microsoft.NET\Fr

  • "the outputpath property is not set for this project" error 2009-07-08

    I have a multi project solution in Visual Studio 2008. I just added a new Configuration called Release-VersionIncrement to the solution, specifying "use release" configuration as baseline. All project files were updated with that configuration. Howev

  • What are the first things people do when starting a new iOS project? 2010-10-20

    world! I recently started diving into iOS development and am happy to announce my first free app has been approved by the App Store (don't worry, I won't spam it on here)! Now that I feel more comfortable with building iOS apps, I'd like to begin bui

  • Array not being populated as expected in iOS project 2011-01-04

    I have an iOS project that has some mp3 files in its Resources folder : I would like to add them to an array. The following would appear to be the appropriate way to add the mp3's to an array, but when I list the array's contents it is empty? Not sur

  • How can I restrict my iOS Project to iPhone 4 Only 2011-01-17

    I'm using a barcode scanner library within my iOS project that currently only supports iPhone 4 devices. Is it possible to restrict the application submission so that only iPhone 4 users can load it, is this a cause for rejection from the App Store?

  • How to use Mailcore framework in my IOS project? 2011-01-25

    i have download mailcore for iphone from .i have try to build it shows error as No architectures to compile for (ONLY_ACTIVE_ARCH=YES, active arch=armv6, VALID_ARCHS=i386) So i can't add this mailcore f

Copyright (C), All Rights Reserved.

processed in 0.164 (s). 11 q(s)