I am trying to provide rotation support, however when transitioning between two UIViews, the autoResizingMask property appear to be ignored.
Here is a video illustrating the problem:
http://www.youtube.com/watch?v=AWtO7J6YNxA
I currently have each UIView (parent and subviews) set to:
uiView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight );
Also, the parent view has:
self.view.autoresizesSubviews = YES;
It looks like when you return from your Web View (Google page) the two views you mention above are being displayed in PORTRAIT mode but the device is in LANDSCAPE. If so you could just store the two views frame coordinates (x,y,width and height) before you transition to the UIWebView page and restore them when you transition back. Of course you would need to check on the return if the device is in Landscape or Portrait mode.
If you saved the Frame coordinates in PORTRAIT mode and you return to the screen from your UIWebView and the device is in PORTRAIT mode then just restore them with
self.myView.frame = CGRectMake(savedValueOfX,
savedValueOfY,
savedValueOfWidth,
savedValueOfHeight);
If the device is now in LANDSCAPE mode then restore them like this...
self.myView.frame = CGRectMake(savedValueOfX,
savedValueOfY,
savedValueOfHeight,
savedValueOfWidth);
Related
I have a simple app with multiple UIViews. I've recently begun work to create a universal app out of it get the auto-sizing and rotation of views working with the iPhone 5 and iPad.
On my very first view, the view comes up as the standard 3.5" display with a white bar beneath it on the iPhone 5 (and beside it on the iPad). There is also a toolbar attached to the bottom of the view and it appears at the place where it would be on a 3.5" display. The strange thing is, when I go to another view and then return to the root view, the view is sized correctly.
I've checked my autosizing for the view - all outside and inside anchors are activated. My view mode is set to "scale to fit," and in comparison to other views, settings are the same. And the strange thing is it comes up right the second time the view is displayed.
Any thoughts?
I found my problem. It was in the didFinishLaunchingWithOptions method of the application.
I changed:
UIView *rootView = self.rootViewController.view;
CGRect rootViewFrame = rootView.frame;
rootViewFrame.origin.y +=[UIApplication sharedApplication].statusBarFrame.size.height;
to
UIView *rootView = self.rootViewController.view;
CGRect rootViewFrame = [[UIScreen mainScreen] applicationFrame];
The app was picking up the hard coded size of the view from the XIB when the view first loaded; now I just fit it within the application frame.
My application contains a Tab Bar Controller and Navigation controller.
Its totally in Portrait mode. Now I have a table view in 2nd tab, clicking on each row of table view will push another view controller which will show a graphical chart, now I want this chart to be in landscape mode where as the rest of application is in portrait mode.
I came to know that we have to rotate the view on our own, now my question is how to rotate this new view in landscape mode. I put some UIView animations in viewWillAppear function, but I want the block-based animation to rotate this view to landscape for me and when I go back it rotate back portrait mode.
Thanks in advance !
Check the device orientation and make the rotation depends on it:
[UIView animateWithDuration:0.5f animations:^{ myView.transform = CGAffineTransformMakeRotation(-M_PI * 0.5); } ];
in my iphone app i have returned yes in the following method ,its worked and screens are rotating but contents are not fitting to the screen when its in the landscape mode
following is the code which i used
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
following is my output
how can i fit the contents of the screen to the screen size when its rotated,,can any one help me, thanx in advance,,
You should reset the views frame when the device is about to be rotated. This should be usually done in willRotateToInterfaceOrientation method.
You can also simply use autoResizingMask which will automatically resize the view when its superView frame changes.
// Add this line in loadView method
self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth |
UIViewAutoresizingFlexibleHeight;
read this tutorial:
http://www.shinstudio.com/blog/programming/rotating-view-in-iphone-app/
implementing willRotateToInterfaceOrientation will be solution
We are just putting user input into our game so the user can enter email address etc. The entire game is Gl with no iOS UI at all. The EAGLView does not change orientation, it is always in portrait, however the game is in landscape and we handle this with a camera transform.
We want to bring up the iOS keyboard and overlay a UITextView for the text input. The UITextView is a subview of the EAGLView. Obviously it, and the keyboard, shows up in portrait as the EAGLView is in portrait.
Without having to change the EAGLView to landscape is there any way I can force the UITextView and the keyboard to show up in landscape orientation?
If I do change the orientation of the EAGLView to landscape to get this working, is there any hit on performance? I have read several times that orienting a GL view in anything other than the default portrait view will give a performance hit, although I can't find any solid evidence of this.
Thanks,
We think we have come up with a solution for this. We are doing two things, one for the keyboard and the other for the UITextView.
For the keyboard we are setting the status bar orientation. The keyboard follows when set.
[UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeRight;
And to get the UITextView to orient correctly we apply a transform to subviews of our EAGLView, which in this case is only the UITextView, as follows.
CGAffineTransform aTransform = CGAffineTransformMakeRotation(M_PI / 2);
[glView UpdateSubViewTransforms:aTransform];
This literally adds a 90 degree rotation to the view.
This has been tested on iPad & iPhone 4 with iOS 4.3, and on iPhone 3G with iOS 3.13.
My statusbar orientation is landscape, I have a cocos2d view that only supports portrait orientation(it is OK since it handles transformations). I have another view that is presented as a modal by cocos2d controller, its orientation is landscape, but whenever I dismiss it, my statusbar orientation somehow changes to portrait, I tried overriding supported orientation methods of container views, but none of them has any effect.
regards
OK, here is how I did it, I thought what messes things up is the fact that orientation of container being different from the view that is presented as modal. So I added another view to contain cocos2d view and presented the modal using that view. The container's orientation is lanscape, so I needed to transform cocos2d view int he load method of its controller.
self.view.transform = CGAffineTransformRotate(self.view.transform, -(M_PI / 2.0));
self.view.frame = CGRectMake(0, 0, 480, 320);
I am still looking for a better way of doing this.