[iPhone]how to add transition animation or overlay view when screen is rotating - iphone

My application has some screens support landscape mode which load some more data and have to re-render GUI, and one of them will load another view in landscape mode. But its seem the screen would be rotated before re-rendered or load another view, it is not nice looking.
So it would be better if there is an animation or a view to be shown when rotating.
Does anyone know how to do this please help me! Thanks so much!

You can do either one (or both); display additional animations or display a different view while rotating. I'm assuming you're working with a UIViewController, check out the documentation (specifically, 'Handling View Rotations').
Override both willRotateToInterfaceOrientation:duration: and didRotateFromInterfaceOrientation: to add and then remove your placeholder view.
You will need to override willAnimateRotationToInterfaceOrientation:duration: to perform any animations.

Related

Iphone View Rotation not functioning properly

I have a simple 1 screen app, with 1 View.. the view contains
a button, an textbox and a button across the top
A segmented controller across the bottom
and a MapView in between.
In portrait mode all is right with the world.. So I decided to begin to allow Orientation change...
in IB all views and elements and even the root window have autoResizeSubviews set
in My AppDelegate and my viewController I have also programatically added SetAutoResizeSubviews to yes explicitely I have set the autoResizingMask in the Root Window and the View Controller to FlexibleWidht | Flexibile Height
I have added the shouldAutorotateToInterfaceOrientation in my ViewController to always return true.
Yet, it doesn't work.. Or should I say it doesn't rotate properly.. in both portrait modes everything looks great, but both landscape modes, things don't get laid out or resized properly.. Basically all I see is the mapview, and its size gets slightly wider, but not much than the portrait mode, and it doesn't fill up the screen top to bottom.. all other interface elements with the exception of one button are invisible and it appears on TOP of the mapview.. as thought it just happened to be layed out over the view by coincidence than any design.
Anyone have any ideas what I am missing, or why?
Thanks in advance
You say "I have set the autoResizingMask in the Root Window and the View Controller" but that is a red herring. It is the buttons, the text box, the segmented controller, and the map view that have to have the correct autoresizingMask. If this view is being designed in the nib, you can set the values there and then turn the orientation right there in the nib and see what happens.
If you are unable to work out good autoresizingMask values for all those interface elements, implement didRotateFromInterfaceOrientation and perform the layout alterations in code when called upon to do so.

Iphone sdk custom uiview orientation issue

I am using custom based uiview controller with uitabbar contains uitableview. I am using image for cell background. I want to do orientation from portrait to landscape but the issue is it is not changing on orientation. I just want to know is there are any special thing for custom uiviewcontroller for orientation?
Thanks in advance
Regards,
sathish
If nothing happens when you rotate the device, you either have the system-wide rotation lock enabled (you checked that, right?), or your view controller isn't returning YES to the alternate orientation in its shouldAutorotateToInterfaceOrientation:, or you're doing something odd with your views that means your view controller isn't getting set as the “frontmost” one and thus isn't getting asked about orientation changes. It'll be easier to narrow that down if you post the code you're using to set up the controller and its view.

iPhone/iOS SDK: Autorotate main view, but not child view?

Here's what I'm trying to do.
I have a single view ("primaryView"), controlled by a customized view controller. primaryView contains a scrollview, which contains an image. Sitting on top of the scroll view (NOT inside it) is a small view ("buttonsView") containing a few buttons.
Basically, when the user rotates the phone, I want buttonsView to autorotate to match the new orientation, but I want the scrollview to remain exactly as it is, and NOT rotate.
Is there a way to do this? Right now, primaryView is autorotating, and taking both subviews (the scrollview and buttonsView) with it, which is no good.
Thanks!
The system will not autorotate unless all visible views consent to autorotation. What you can do, then, is to detect orientation changes, and set an appropriate affine transform for the non-rotating views, essentially to undo the system's rotation.
You can use willRotateToInterfaceOrientation:duration: to fade out the controls, then didRotateFromInterfaceOrientation: to fade them back in at the correct location.

How can I smoothly transition between separate Portrait and Landscape UIViewControllers?

I'm using Apple's sample code for having separate Portrait and Landscape view controllers (presenting/dismissing a modal view controller from within the orientationChanged method). However, it creates a number of problems:
The status bar doesn't rotate. If I manually setStatusBarOrientation, I get very strange behavior.
The transition is very abrupt; I prefer
the conventional smooth animation,
especially because...
90% of the
view changes, but there are two
images which should look exactly the
same (same size, same position, same
orientation) in both the landscape
and portrait modes.
My goal is a rotation transition more like the one in the Stocks app. How can I achieve this?
Thanks.
You could use core animation to do that. Fade out all elements that don't appear in the other view (by animating the opacity). Move and rotate the objects that are the same in each view. And finally fade in new objects in the second view. It might get rather complicated, depending on the complexity of your view. Have a look at these methods to find out where to implement the animations:
– willRotateToInterfaceOrientation:duration:
– willAnimateRotationToInterfaceOrientation:duration:
– willAnimateFirstHalfOfRotationToInterfaceOrientation:duration:
– didAnimateFirstHalfOfRotationToInterfaceOrientation:
– willAnimateSecondHalfOfRotationFromInterfaceOrientation:duration:

Is it possible to auto-rotate a modal view but not its parent?

It seems that if a modal view's parent returns false to shouldAutoRotate... the modal view will also not autorotate. How can I have a main view which will never rotate, and a modal view which will always rotate?
You may try to observe for orientation events (UIDeviceOrientationDidChangeNotification) in your modal view controller and then add a transformation to your view layer using the CATransform3DMakeRotation to get an appropriate rotation around Z or basically with
[myLayer setValue:[NSNumber numberWithInt:M_PI*0.5f] forKeyPath:#"transform.rotation.z"]; // or - M_PI*0.5f depending orientation: left or right
You can also use an animation to get an animated rotation. Is it what you're asking for?
For observing orientation events read this chapter :
Getting the Current Device Orientation
For Layer transform read this chapter :
Layer Geometry and Transforms
Regards.
V.Zgueb
Yeah, sure you can. Pretty much same advice like here I've posted recently just in different direction.
You need allow rotation on Modal, witch is by default. And disable it on Main controller.
This should work fine.