How to resize the UIWebView content size on orientation? - iphone

My application has a UIWebView which consists of an UIImageView as its subview, when i change the orientation of the device, the image in UIWebView is not affected and it remains in the same position as before. So is there a way to fix this issue. i want the image to automatically allign to its respective orientation.

How about use "Size Inspector". Set as below, the image view will move to new position.
Can you see what I have done in this picture? I removed all red lines around square so that the view moves to keep ratio of distance to edge of screen.

Have a look on the autoresizingMask which defines how the view behaves if the superviews bounds changes. In Xcode you can do it in the Interface Builder/Size Inspector.

Related

UIImageView does not fit my screen properly

I have a UIImageView that fills up the majority of my screen, with the exception of a navigationBar at the top. On my storyboard, I am using the formatting mode titled "compact width|regular height" that is supposed to work for all iPhones in portrait mode. When I attempt to run my app on an iPhone 5c, with iOS8, the imageView does not fill to fit the screen, and appears to "spill out" of the screen, based on the size and positioning of the image within the imageView. I do not have any auto-layout constraints on my imageView, because when I attempt to put them on they enlarge and distort the image even further. I have tried Scale to Fill, Aspect Fill, and Aspect Fit, and none of those work. I have also made sure that the clip to subviews selection button has been checked, so that the bounds are clipped. If anyone can help me, I would really appreciate it. Thanks!
You can disable the auto-layout and use the autoresizing mask.
I used this on images and fixed the prob like yours that I had.

How to keep image size when changing iPhone orientation

I have an image that's 575x300px with text inside it.
While the iPhone is in the landscape position everything's dandy, but change the orientation to portrait and the image 'shrinks' in size (resolution change?) and the text becomes unreadable.
Is there a way to maintain the image size for both orientations?
Edit - I'm talking about a web page, not an app.
Set the view's contentMode to the value you would like. You probably want a value like UIViewContentModeScaleAspectFill.
try to set the autoresizing mask property for the UIImageView to UIViewAutoresizngmasknone.

Rotating UIView and background to landscape mode

The initial root view controller is 9 (3x3) buttons with a custom background in portrait mode. When the device is rotated into landscape mode the last row of buttons (of course) are cut off and the background (which is 320x480) doesn't fill the width of the screen.
What is the proper way of handling this? Do I need to move and resize the buttons myself? Do I have multiple Nibs? How do I resize/rotate the background?
Use shouldAutorotateToInterfaceOrientation and/or deviceDidRotateSelector in your viewController to reposition / layout & scale your views programmatically as you require.
If you set the auto-resizing masks on the buttons to have flexible margins in all directions they should reposition themselves appropriately when you rotate the device. You can do this either in code, or in Interface Builder (which has a nice little simulator demonstrating the effect)
With regards the background, what I prefer to do is to make the image the combination of the maximum proportions of each orientation, and then center it. For instance, make your image 480 x 480, make the view that houses it the same size and then use the appropriate auto-resizing masks to achieve the desired effect.

Problem UIview size after re-orientation

First,I am sorry for my poor english...
So, i have a problem with a view which is added on a other one.
I am setting size of UIview in IB as 200px/200px
I set the center of this view with the center of parent view.
Everything is working great at this point.
I can see my View in the center of the parent view like i want.
Then I set the - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
And that's working to.
But when i rotate the iphone, the size of the view change to full size, the view don't want to stay in center and go on the top left of the screen and resize as fullscreen...
Can somebody help me with this problem ?
Do I have to set the frame and the center after rotate ? That can't be automatic ?
Thank you!
In IB, under the "Autosizing" section, remove the "arrow" that indicates auto width/height of your component.

trouble with rotating view (and resizing elements within) in ipad application

I'm having a nightmare with the rotation on iPad. I've searched all over the place for some tutorials, but nothing seems to really be for what I want. (Possibly not searching for the right thing?!)
I have a portrait view by default which is an image and a button inside the view. When I rotate, I detect this can work out if it's landscape. I then try to set the frame size of the uiview to fit nicely on the screen.
If I let it autoresize, it simply stretches and fills the screen. This I don't want.
but the trouble is, when I resize, the button gets resized too, but not in the same ratio as the image.
My question is: What's the best way to resize the view. I wanted to simply reduce the uiview by say 60% and it resizes EVERYTHING in that view with the same 60%. The only way I see this is working at the moment is to create two views... but that's twice the work and maintenance!
I've tried messing with the autosizing arrows in Interface builder, but that again seems to screw things up more!
I'm completely lost here!! Thanks for any info
The problem you have there is that the view is automatically resized to the screen ratio. On an iPad in Portrait Orientation the screen size is 1024x768. After the rotation to Landscape the origin rotates too and your screen content is skewed or stretched to 768x1024.
What you need to do is to override the
-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
message of the UIViewController of the view which rotates. This message is called within the animation block of the rotation. You just set the framesize of your subviews (the button) to whatever is best for you. Once i had a problem with rotating an OpenGL view. The content of the view was stretched when rotating to landscape. Since it is not possible to alter any OpenGL matrices within the animation block the only solution i found was to make the view quadratic and to set the origin behind the bounds of the screen (in -x direction). You have to override the message also to reset the origin above the screen (in -y direction) bounds in landscape mode, to keep the viewport in the middle of the screen. That way the view kept its ratio. Whatever solution is best for you, overriding this message should work out.
Have you tried disabling the autoresizesSubviews property on your UIView? It should prevent any size changes on the subviews when you resize your view.