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.
Related
I have a UIView with labels and textfields and I tested it in the simulator and noticed that I cannot scroll to see the rest of the view, how can I make the view into a UIScrollView and what do I need to do so I can make the view scrollable? I don't want to move labels and stuff or delete the UIView, is there a simple way?
Take a UIScrollView in Xib file outside your view. drag your view into this scrollview. The subviews inside your view remains same. and set the scrollview's contentSize
iPhone Interface Builder question: Does anybody know how to add a small UIView over a ScrollView yet the image should stay still? Basically I already have a full image (320 x 480) over the Scroll, so the image scrolls, but now I need to add a AdMob View (320 x 48) on top of them. The problem is after i build and run, the ad scrolls as well. How do you make it stay still?
Thank you!
Not sure if this is how you've done it in your code, but if you've added the AdMob view as a subview of the scroller, then it will scroll.
It should not scroll if you add it as a subview elsewhere, either the superview of the scroller or the window itself.
I admit though that I generally do not use Interface Builder and would generally handle this programmatically, but I hope this helps.
Just place the AdMob view at the same hierarchical level of the ScrollView but being in front. Then when the Ad is available, set adMobView.hidden=NO, when it is not available set adMobView.hidden=YES. Essentially the hierarchy is:
RootView -
|---- UIScrollView
|----- any UIView (to be scrolled)
|---- AdMobView --> not subview of ScrollView but subview of RootView
Of course when the Ad is visible you will not be able to tap on it to scroll, unless you subclass it to pass the tap to next level in hierarchy. But probably you have not this problem thanks to the reduced size of the Ad (48) with respect to the entire scrollView (480).
I have a TabBarController with 4 views, and one of them is a scrollView. If i load this view, and then change the orientation of my device from portrait to landscape, the scrollview responds to the touches only 'till the pixel 320.
If later i go to another view, and then come back to the first, the scroll view works well even in landscape.
How can i adjust this?
Your scroll view is probably not set to automatically adjust its height and width. If your view is built with Interface Builder, use the Autosizing section of the Size Inspector to set the struts & springs. Otherwise, if you're building your view programmatically, you'll need to set the autoresizingMask property to something appropriate.
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.
I have a UIScrollView subclass with a certain subview I'd like to prevent from scrolling (while all the other subviews scroll as normal).
The closest example to this I can think of is UITableView's "index strip" on the right side (look in the Contacts app to see an example). I am guessing this is a subview of the table (scrollview) but it does not move as the user scrolls.
I can't seem to make my subview stay put! How can I accomplish this?
The trick is to adjust the frame of the "non-scrollable" subview inside -layoutSubviews.
Add the view that you want not to move as a sibling view of the scroll view on top of the scroll view instead of as a subview.
You can set it's property called userInteractionEnabled to NO