views:

1458

answers:

1

I have an IPhone application that I want to attempt login and do some initial setup before showing the UI. I currently have my Default.png set to an image and I have a view that has that same image. When my app loads the Default.png loads and then my loading screen loads. The loading screen is the view for my root view controller in the MainWindow.xib. After loading my app will show a tab bar controller that is created programmatically in the root view controller.

I want to be able to animate between the loading view ( which is defined in MainWindow.xib) and my tab bar controller ( defined in the root view controller ). I am just doing

self.view = tabBarController.view;

to switch views. I have noticed that that doesn't work when wrapped with UIView animations. My question is how should I be switching views. I tried addSubView and insertViewAtIndex and these both do the animation, but leave the 20px status bar gap at the top of the screen ( underneath the already existing status bar ). I assume there is something simple, but I'm not sure what it is.

+1  A: 

You should not do self.view=tabController.view...what type of animation do you want? Have you considered using a NavigationViewController ? pushing to the NavigationController s tack will allow you to animate the transitions (pushing the new view in). Other options you have without using a navigation view controller is using presentModalView:animated method in UIViewController, you can also define your animations when using addSubview, the metronome example project in the apple site shows how to go about it when y ou click the info button heres a link https://developer.apple.com/iphone/library/samplecode/Metronome/ . hope this helps

Daniel
Should I not do self.view=tabController.view for animation - or ever? I have had questions on working with my view heirarchy in the past. I am doing this because I basically want my root view controller to be a tab bar controller. I've had issues with the addSubView - like the 20px status bar gap at the top of the view.
Brian
I had not thought about using a Nav controller for just managing multiple views when I'm not drilling down into something. Is this a common practice?
Brian
I dont t hink its good practice to do self.view= some other view at all...the 20px status bar gap can be due to your views having rects (some of 460 and some of 480) which can confuse the UI system. Yes i t i s very common practice to use a nav controller do drill down to multiple views, you can see it used everywhere
Daniel
I may have misspoke, I was asking if it was common to use navigation controllers even when NOT drilling down through views, but rather to hold and display separate views? Also, if doing addSubView with a TabBarController's view, how can I specify the rect so that it is 480 rather than 460? Thanks for your help.
Brian
O ok, then maybe not, to specify the rect if the view i s named v then you can do v.frame=CGRectMake(...)
Daniel
o tabBarController.view.frame...
Daniel