iOS opening animation - iphone

I am currently executing my own version of this opening animation
http://www.raywenderlich.com/2454/how-to-use-uiview-animation-tutorial
The animation runs perfectly however once the default.png disappears and my animation starts the UITabBar and the UIPicker I have loaded in the first view are sitting above my animation when it plays.. I am wondering how to make sure this animation plays above everything.

Before running the animation, call:
[self.view bringSubviewToFront:basketTop];
[self.view bringSubviewToFront:basketBottom];
[self.view bringSubviewToFront:napkinTop];
[self.view bringSubviewToFront:napkinBottom];
This basically pulls those 4 objects to the front of the view, so they are on top of everything else. You might need to play around with the order in which you bring the 4 to the front.

Except for the z-order you should check that the view you are trying to animate has the proper size, otherwise it can't possibly cover the whole screen. And of course check your view's superview - if the superview covers only the area between UITabBar and UIPicker it won't cover them, ever.

In your application:didFinishLaunchingWithOptions: you could present a modal view controller and perform your animation(s) inside of it then remove the controller.
Or you could perform those animations on the window.
Since the controller's view is inside a a tab bar controller, its view doesn't cover the tab bar and therefore cannot show over it.

Related

Subview behaves strangely in navigation-based app

I'm currently developing an app for iphone (my first) and I used several UITableViewController for navigation.
I then used a subview attached to self.view.superview to get a non-scroll image at the top.
The subview is created in IB, simple UIView with an UIImageView in it.
I'm adding the subview in viewDidAppear and this functions well.
But as soon as I'm tapping a cell and the navigationController pushes the next View animated, the previous view (scrolling out of sight) becomes completely white and my subview moves animated to the center. It's only for a half second or so, because then it's gone due to the next view arriving, but it's really unnerving.
I tried removing the subview in viewWillDisappear, that removes the UIImageView, but the screen still becomes completely white.
Does anybody how to fix this?
Oh, and PS: I'm working only on the Simulator, because I have no Developer Account yet. And I cannot change everything to a ViewController because I have a deadline to meet.
You shouldn't be surprised that things go wrong when you mess with the views of view controllers that don't belong to you. Rather than using a table view controller, you should replace it with a custom UIViewController whose view acts as a container view for both the table view and the non-scrolling view above it.

problem in tabBar Controller with more than five tabBar items

I am facing few problems while using tabBar with navigation controllers.Each tabBar item is associated with a separate navigation controller.Problems are listed as follows:
1.There are more than five tabBar items in my tabBar so a more tabBar item comes by default.Now when i tap the more tabBar item the remaining items come in a tableview which is actually the view of a navigation controller(which comes by default).Now when i select any of the row, my new view controller gets pushed into that navigation controller.I want my view controller to be the navigation controller.So there is a situation like pushing a navigation controller onto the sack of another navigation controller.The compiler gets confused and it does nothing.
2.Although I have set autoresizing of each controller of tab bar controller nothing happens on rotating the device.However when I keep only five or less tabBar items,autoresizing works perfectly.
3.I want an ImagView at the top throughout the application, so I attached an imageview on the window itself and than increases the y-coordinate of the tabBar controller's view so that the navigation bar of each tabBar controller's view starts just below the imageview.Everything is fine for the portrait mode but as soon as i rotate the device the imageview dissappears.And when i again come to portrait mode the imageview does not appear and the tabBar controller's view starts from the top.
I tried it every ways(like tabBar instead of tabBar controller etc.) but fail to achieve anything helpful.
I've never heard of that problem before. Can you paste some code? Also, are you sure that the tabs on the view more page work correctly?
In order for a TBC to rotate, all of the root view controllers of each tab must support rotation. In each of those files make sure shouldRotateToInterfaceOrientation: returns YES for all orientations (if you're using the default iPhone VC template take out the if(interfaceOrientation == UIInterfaceOrientationPortrait) statement and associated brackets).
I've actually done this before, and trust me when I say you're opening up a can of worms. To achieve this you need to add the TBC as a subview of a view that has an imageview on top. You must manually set the TBC.view frame to not cover up the top image. The best way to do this is: in the .xib for the container file, add an image view up top, and under it another view. Connect the view to the code via an IBOutlet, and set that frame as the TBC.view.frame. Then add the TBC.view as a subview programmatically.
With this solution, however, you must add in a willRotateToInterfaceOrientation:duration: method that calls the same function in all the TBC's viewcontrollers, and all of those viewcontrollers must be navigation delegates that call viewWillAppear: and viewDisappear: manually. The rotation is also a bit "sticky" when you do this, so beware.
My suggestion: don't put a static image up top. It causes a lot of issues, and takes up a lot of screen real estate, especially on the iPhone's smaller screen. Look at The Weather Channel app if you want to see how bad it looks.
Let me know if you have any more questions!

resize uinavigationbar push/pop viewcontroller size issue

i need to shrink the height of a UINavigationBar (attached to the UINavigationController)
i've done this via the UINavigationControllerDelegate's navigationController:didShowViewController method, and it's working fine.
the problem is the visible viewcontroller that's in the main view. it wasn't resizing itself to reflect the new navbar height. thus, the didShowViewController method also resizes the viewcontroller's view frame, which works fine.
however, when i go to push on a new ViewController, or pop, i always see the view shift down to the original position during the animated transition to the next view. then, due to the code i have in the didShowViewController in the NavControllerDelegate, it shifts it back up.
i'm curious as to the best way to ensure that the shift down never happens.
i tried placing the code that resizes the frame into the willShowViewController, but that doesn't do anything.
i've also made sure that the UIView's frame that is the view of the UIViewController that's being popped, is also of the proper/shifted dimensions. no go there.
it's like i need to intercept the drawing actions after the pushViewController is invoked, and before the UINavigationController's didShowViewController is called.
i've been staring at my code for hours & hours... not getting anywhere. hopefully this makes sense to someone out there.
thanks!!!
Another option I think would be to set the NavigationControllers navigationBarHidden equal to YES. This will hide the nav bar completely and then you can then draw whatever view you want in the place the bar would have resided. Just put controls on the view that wrap the navigation methods (push, pop, etc...). It might be a challenge to get it to have the same style as a nav bar though.

Displaying UIImagePickerController within another UIView

I've been working pretty extensively the last couple months with UIImagePickerController, particularly with the new capabilities in OS3.1 and newer to overlay views on-top of the camera view. This has worked just fine.
However, I am currently working on a project where I'd like to be able to display the camera view of the UIImagePickerController within an existing view. Essentially, the exact opposite of what I've currently been doing.
An example would be a View Controller with navigation components (Think top and bottom horizontal bars with gradients), and upon tapping a button on one of these bars, then content area displays the camera view. The shutter animation would should up, and the top and bottom navigation bars would remain always on-top.
I've had success adding the UIImagePickerController to the window view, as well as presenting it modally, but haven't had any luck adding it as a subView.
ex:
[window addSubview:camera.view];
[self presentModalViewController:camera animated:YES];
All you need to do is call viewWillAppear and viewDidAppear.
Here is an example where _pickerController is an instance of UIImagePickerController:
[self.view addSubview:_pickerController.view];
[_pickerController viewWillAppear:YES];
[_pickerController viewDidAppear:YES];
Call viewWillAppear:YES on the image picker controller after adding its view to your view. Skip the modal view controller business.
I don't think the API provides direct access to the actual view of the UIImagePickerController. The class is actually a subclass of UINavigationController so I don't think it has an actual view itself but rather manages the calling of its subcontrollers and their views.
When you call the UIImagePickerController modally, its doesn't add the views it controls as subviews to the window (or any other view). That is what a modal view means. It presents the view off to the "side" of the view hierarchy.
Even if you could hack this together, I think Apple would reject it as not being part of the API and for violating the HIG.

ModalViewController doesn't display during animation when paged scrollView is scrolled

My application has a paged scrollview. Each page of the scrollview has an instance of a view controller (buttonViewController) that shows a grid of buttons. If the user clicks on one of the buttons, buttonViewController launches a detailViewController modally, with animation set to YES.
If I'm viewing the first page (furthest left) or the scroll view, everything work's correctly. However, if I am scrolled to any of the other pages, the modal view animation (sliding up from the bottom in this case) doesn't appear. Instead, the whole view goes black for the same length of time that the animation would run for, and then the modal view controller appears fully displayed. The same thing happens when dismissing the modal view controller.
The code is completely standard. In my buttonViewController I call:
[self presentModalViewController:detailController animated:YES];
The same code runs no matter which page I'm looking at (though on different instances of buttonViewController of course.)
How would I start debugging this?
This might have to do with the frame of the detailController...When you are in a UIScrollView, the first page is between 0 and 320, however when you scroll that offset increments, so (assuming you have full screen pages) the next view will be 320 and 640, the next one will be in 640 and (640+320), and so on and so forth. So when you are setting up your detailController with frame CGRectMake(0,0,320,460), when you are in the first page, the animation will look fine, but when you are in any other page the animation will take place at (0,0) and then im guessing the viewcontroller sees this is not the active screen a nd moves the modal view controller to where the active screen is. If you initialize your frame like this CGRectMake(320*pageNumber,0,320,460) I think youll have the d esired behavior you are looking for. Let me know if this works im curious myself.
You need to insert a UIView (or any kind of view e.g. UIScrollView) under the view you are trying to animate, you will get the animation work correctly. I guess this is because you are providing a view that the animation is based on.