How to resize UIScrollView on rotation? - iphone

For my project I've created an UIScrollView with an UIImage inside. The Scroll View is as big as the window frame (tab bar application). What I want is to resize the UIScrollView again when the user rotates the device. How can I do that?

You could just set the autoresizing mask either in Interface Builder, or through code, depending on which way you created the UIScrollView in the first place.

Related

Resizing a UIView containing UIButtons makes those buttons lose perspective position

I got a UIView that contains an UIIMageView and several buttons that are allocated on certain position related to the image of the UIIMageView.
The frame of the UIView is (0,0,250,250)
the UIIMageView that is within the UIView is set to autorisizing (all) in IB.
All buttons are set to autoresize (none) and origin middle.
When i change the frame of the UIView i.e (0,0,500,500) the UIIMageView (and image) resize OK but the buttons lose their perspective position by a few pixels (about 2 to 3 in the vertical and horizontal axis).
Is this normal? can someone advise?
Try putting the buttons inside another UIView and then setting the autoresizing options on this new view. You should leave the buttons without autoresizing inside the new view.
there is no answer after all.
I must accept the fact that the resized view and the buttons within it will lose perspective position by 2/ 3 pixels off the x/y axis...
strange....

iPhone : TabBar overlaps above UIScrollView

I have created an iPhone UI programmatically but I just can't figure out how to fit a view so that it doesn't get overlapped by the TabBar. Here's the ownership hierarchy:
- AppDelegate
UITabBarController
UINavigationController x
UITableViewController
UIViewController (with XIB)
UIScrollViewController (in the same XIB as parent)
The problem is that my TabBar hides a part of my UIScrollView (and my tableviews as well, but that's not important). I tried manipulating the scrollview content size and the view frame size but with no luck.
So far the best I could do was to add a 60px padding on the scrollview's content size like this:
[scrollView setContentSize:CGSizeMake(self.view.frame.size.width, self.view.frame.size.height+60)];
Thanks for your help!
Sounds like you may have to make sure your scrollView's frame is set properly first. The contentSize will determine the dimensions of the content of the scrollView. In other words how far you can scroll in each direction. Take a look at the scrollView in your nib and make sure the frame is the right size you need to fill.

Resizing content in a UIScrollView

I am creating a scrollview programmatically and adding subviews to it programmatically. The subviews are created programmatically as well.
I am just wondering how to rotate / resize the subview so that it remains visible in landscape mode.
I have set the scrollview to autorotateSubviews:YES and in my subview i have set the mask to be flexiblewidth|flexibleheight is this correct?
I am used to doing this in IB with the springs and struts section of the inspector.
Thanks
Your scroll view is probably contained in a view witha corresponding controller that receives willAnimateRotationToInterfaceOrientation:duration: and didRotateFromInterfaceOrientation: notifications. Use these opportunities to resize the subviews of the scrollview.

iPhone - strange issue with UIScrollView and touches

I have two UIImageView objects inside my view (both 320x480 one above the other). The lower image view is inside a UIScrollView with scrolling and zooming enabled. Now I want to handle touches inside the other image view but it no longer detects any single taps.
I can understand that the UIScrollView handles all the touches which I do on it. But the touches on the image view above the scroll view are also not recognized.
Attached is an image with my view hierarchy. Can someone please tell me why the other image view's touches are also handled by the scrollview when it isn't a subview of scroll view?
And if the scrollview is bent on handling touches, how do I recognize touches on the other image view?
Thanks.
By default UIImageViews have userInteractionEnabled=NO;
Try setting it to YES (either in IB or in code).
I'm not sure, it might be that you need to set the frame size and/or content size of the scroll view properly. This page has a diagram of what I'm talking about.

How resize sub views along with super views

I want to resize super view in different orientations with subviews.
I have an image view and I am adding different subviews in this image with layering.
Please tell me how can I resize all parts of image on different orientation.
if you have an image inside an uiview for example, if you rotate the uiview the content inside will change with it.
same for resizing.
i do my resizing manually when the orientation changes ( i use an observer to listen for changes on the orientation, and manually change my size using CGAffineTransform )