DatePicker control resizes when rotated - iphone

I have a landscape view that has a datePicker control on it, which was designed using IB. The datePicker control loads correctly the first time the view is loaded. If I dismiss the view and then load the datePicker view again, without rotating the app back to portrait first, the control resizes. If I load the datePicker, dismiss it, rotate the phone to portrait, then call the datePicker again it works fine. Is there a way to trick the app into thinking it was rotated back to portrait without actually rotating it? Is there any other reasonable way to deal with this?

If you dont want to rotate it on orientation, you can transform it manually. Hope I understood correctly what you were trying to explain.

Related

Changing parameters on iOS device orientation

I have a Tabbar project in which one one the tabs should be on landscape mode. I've seen than the Tabbar controller only allows it only if all its views allow it. Son now I'm somehow forced to adapt all the views for both portrait and landscape mode, which I've never did before.
Am I right assuming that all should be done under:
-(void)willAnimateRotationToInterfaceOrientation...
so what happens with subview which are lazyly initialized? such as a footerView on a tableView?
Another thing is, I have a method to scroll the tableView so nothing is kept under the keyboard when it's called. The method uses a constant float + a variable. In landscape mode, the constant should be another.
Any feedback would be appreciated. Thanks in advance!
Read up on autoresizingmask - setting this attribute on your views will automate a lot of the orientation resizing.
And yes, you'll need a landscape and a portrait value for your constant.

How can I manually rotate the keyboard (With animation)?

I have a controller that manages a UITextView. Normally, in an app that supports multiple interface orientations, I would simply override -shouldAutorotateToInterfaceOrientation:, set the appropriate auto-resizing masks, and go along my merry way. While going along my merry way, if I were to begin editing this UITextField in, say, portrait mode, then rotate the device to a landscape orientation, the keyboard would animate nicely to landscape mode along with the rest of the view. This is what I want.
Now, in this particular app, I have a root view that must only ever be in portrait mode. This is a camera preview view. I also have an overlay-view for the camera-view that I would like to have support all interface orientations. This is where the UITextView is located.
So, as a result of the fixed-orientation root view, I cannot use built in rotation: I have to do this manually. This isn't a problem, I can register for the UIDeviceOrientationDidChangeNotification and manually animate the appropriate rotation and frame adjustment for the overlay view.
That's good enough to get the view positioned correctly, but the keyboard would still only ever show in portrait orientation. Again, I can correct this with UIApplication's -setStatusBarOrientation: every time I get a notification that the device has rotated.
But that's where the problem arises. I would hope that the combination of:
Register for rotation notifications
Manually rotate view
Set status bar orientation (with animation)
would be enough to exactly replicate the automatic rotation behavior. But it falls short in one important way: If the keyboard were to be shown in one orientation, then rotated to another, the keyboard would remain defiantly in the original position, as if -setStatusBarOrientation: were never called. As far as I know, the only thing that affects the keyboard's presentation is the application's status bar orientation, and there is only the one method for setting it. So am I out of luck? Is it really impossible to make the keyboard rotate with a view manually like it does with auto-rotation?
Addendum
In an effort to avoid covering old ground, I've tried the following solutions hacks:
Upon orientation change, resign and immediately become first responder again. This does make the keyboard move to the appropriate orientation, but it does so without animation, and occasionally does really bad things like show a landscape-sized keyboard in portrait and vice-versa.
Upon orientation change just resign first responder. This also has the odd behavior of instantly moving (but not resizing) the keyboard to the new orientation, then dismissing it with animation. It's very ugly and jarring.
One of our apps does this (because we didn't say "no!" loudly enough when presented with the original design) using crazy "orientation stack" code. I remember fixing this problem by disabling orientation when the keyboard is up (ickyyyy).
Instead, consider supporting rotation by "counter-rotating" the camera preview view instead of forcing the VC to portrait-only. If this looks a bit odd, you can do the "nasty hack" version: Add the camera preview view as a subview of the window, under your VC's view, and give your VC's view a transparent background.
Maybe late to the party. I stumbled upon the same problem. Trying to fix it in iOS 6.
Apparently Apple didn't recognize this problem in the meanwhile, otherwise they would've fixed it by now: have the -setStatusBarOrientation: method include other interface elements besides only the status bar as well, or have alternative methods to set the orientation of the keyboard and other elements. A pity they didn't
Disabling orientation rotation when the keyboard is up, is no solution for me, but I found another simple solution hack:
return NO in -(BOOL)shouldAutorotate
return UIInterfaceOrientationMaskAll in -(NSUInteger)supportedInterfaceOrientations
listen for device rotation notifications
Then when you receive such notification:
hide the status bar
when the keyboard is up, dismiss the keyboard ([myTextField resignFirstResponder])
perform manual rotation animation
set the orientation of the statusbar ([sharedApplication setStatusBarOrientation:newOrientation animated:NO])
show the status bar
if the keyboard was visible before, present it again ([myTextField becomeFirstResponder])
The effect is that the status bar and the keyboard gently slide out before the manual rotation animation and gracefully slide back in, when the animation is done.
BTW, I also found this interesting article by Corey Floyd: http://coreyfloyd.tumblr.com/post/8212203583/2-ways-to-rotate
Although his second method: Tricking UIKit, only caused more confusion with me.

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.

iPad Rotation and Keyboard pop up

I'm building an app that uses a UIView that contains a UIScrollView within it so that when the keyboard shows up, users can still scroll downwards to see the content within the view. It seems like I have gotten everything perfectly set up but when I rotate, everything goes completely unusable. The views are all out of place and I am unsure what's the strategy to handle this. I have the views autoresizing but they don't seem to be doing it correctly.
Should I manually check to see if the rotations have occurred and reset the frame without autoresizing or is there a way that I can accomplish this with auto resizing?
The situation is this:
Portrait mode - form fits fine. When keyboard shows up, scroll view is resized but form does not.
Landscape mode - form doesn't fit fine and when keyboard shows up, scroll view is messed up.
Do I need to resize the form view when rotated to landscape mode?
Thanks!
You can reposition things back to original by using:
-(void)willAnimateFirstHalfOfRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
//reposition code
}
I have an issue where I want the keyboard to resign upon the ipad rotating.
If the keyboard is open in portrait, and I rotate to landscape, the keyboard appears in landscape.
HOW DO I RESIGN the keyboard when I rotate!
TY

How to change UIViewControllers like iphone Calculator app does?

in my app when the phone rotates i want to change the view like the Calculator app does, when it is in portrait it shows the normal calc and when it is in landscape it shows the scientific calc. For example in one of my UIViewControllers, for portrait mode, i will have a grid with images and when it is in landscape i want it to show an image and to be able to swap them like in the Photos app. Could you give me any pointer how can i swap the viewControllers on rotate?
thank you in advance, Sorin.
You dont swap view controllers, you swap the view, so create a view for each and then when it rotates push the new view in