UIScrollView not scrolling off screen? - objective-c

I have an app in which a UIScrollView of the dimensions 1056x96 on top of a screen which is 480x320 (it is in landscape.) It contains 9 UIBUttons. It definitely is able to scroll, as when I set 'bounces horizontally' to true I can clearly see it bouncing back as soon as I attempt to scroll. It simply will not scroll beyond the bounds of the screen, and I have set its contentSize to 1056x960. Does anybody have a helpful suggestion as to why this is happening? Thanks in advance!

It appears that the contentSize property must be larger than the size of the UIScrollView its self. Once I made the size of that larger, it seemed to work fine.

Also, make sure your viewForZoomingInScrollView is set to the subview rather than the scroll view itself. For example:
- (UIView*)viewForZoomingInScrollView:(UIScrollView *)scrollView{
return self.menuView;

Do you have 'userInteractionEnabled' flag set to true?. Is the scrollView embedded into another view?. If so... please, check the 'userInteractionEnabled' flag as well.
Besides that, please, check if the flag 'scrollEnabled' is enabled both in your nib and in your code.

Related

ScrollView to disappear before the top of the screen

I have a scrollview that I want to have disappear as it scrolls across a certain point on the screen. So as you scroll, the elements on the scrollview will disappear instead of covering up the elements behind it. But if you scroll back down, it reappears. How can I set a point on the screen that will hide the scrollview once it hits that point? I would like to accomplish this without having it "hide" behind another object. Thanks.
Almost forgot, it's all code, no IB used.
You could set the scrollView's clipsToBounds property to true?
Or, if that's not what you're trying to do, you'll need to intercept the scrollViewDidScroll: method and use the contentOffset of the scrollView to determine a threshold at which to make it (or its contents) disappear.
It's late in the day, these things happen. All I had to do was set the scrollview to proper size and location on the screen and it works great. Setting the ScrollView to the proper x and y and width and height fixed the issue. The upper edge makes the elements disappear when they pass the edge. Thanks again for the help, I'm going to figure out the contentOffset as I'm sure it will be needed one day.

UIImageView overlapping effect inside a UIView

Check this URL http://krystalrae.com/
Scrolling down you will see a girl's cloths are changing on mouse wheel scrolling.
I have to create a iPad application where 3 images will appear likewise. The difference will be that in my case image change will occur horizontally rather than vertically in website. Also, i have to make it inside UIView with events touchesBegan, touchesMoved, touchesEnded and touchesCancelled
Help will be appreciated.
Thanks.
From your comment I gather that the problem is the resizing of the images in UIImageView when changing the bounds of the view.
You can set the contentMode of the image view to something else. The default is UIViewContentModeScaleToFill which is not what you want.
You could, for example, set the lower image view to UIViewContentModeBottom, and the upper image view to UIViewContentModeTop.
Don't forget to make sure your image views have sett the property maskToBounds set as YES.

iOS stretch image to full screen

I have a scroll view with a image view inside. I was wondering whether it's possible to have the image inside the image view be much smaller than the resolution of the screen, and somehow be able to stretch it to fit the screen.
Set contentMode on the UIImageView and change its size.
[UIImageView setContentMode:UIViewContentModeScaleToFill];
Check the docs for more informations regarding UIViewContentMode:
http://developer.apple.com/library/ios/#documentation/uikit/reference/uiview_class/UIView/UIView.html#//apple_ref/doc/uid/TP40006816-CH3-SW69
Sure, just change the bounds of the imageView.
Am I missing something here?
Your UIImageView is within an UIScrollView I understand?
That would work by adjusting the scroll view plus adusting the image view appropriately. However that is not advisable to do. You will get lost in small errors with annoying effects.
I'd suggest to add an additional UIView that can match the bounds of the screen.
Add that view to the underlying "view" object and use the bringSubviewToFront method.
You could as well make sure that this new UIView is the first subview of the most underlying view object. You could achieve that by manipulating the subviews array structure - which I do not recommend in general wihout having fully understood everythng about the view hierarchy.
You can as well achieve that by adding the additional view at first before adding any other view. (Within IB just make sure that the new view is the topmost in the tree, coming next to the view controllers "view".) And then make it hidden until you actually need it. Then you unhide it. When it is not needed anymore then hide it again and neither delete it nor erase it from its superview.

UISwitch not responsive in UIScrollView

I'v encountered strange bug, and have no idea why this happens.
I have UIScrollView, in it I have 12 views. Most of them contain UISwitch button and a label. Size of views are dynamic (depending on the lenght of label.text). Everything works and shows, except two views on the bottom. They do get shown, initialize as expected. Yet UISwitches in them do not work, clicking or touching them does not do anything. Both of them are no exception to others (all of them are copy paste). I have double checked IBOutlets, they are fine. I have suspicion something is wrong with scrollView. Maybe beyond some point it doesn't recieve inputs anymore? Eventhough I can scroll up and down and everything is shown just as expected.
Any ideas what to check ?
I have switched these two views with first ones. And more bottom views get unresponsive, like there is a line, beyond which ui is not responsive. Ideas?
You say the switch is in a view (one of 12) and that view is on the scroll view,
maybe the UISwitch is out of the view bounds? Try to set that views .clipsToBounds = YES;, can you still see the switch? If no, it means the switch is out of bounds therefor you gat no touch events. Make that view larger to fix that.
Check correctly. if the UISwitch and UIscrollview user interaction are enabled.
Check whether the UISwitch is added within the UIscrollview's frame.

NSScrollView scroll downward when resizing?

I have a NSScrollView with a custom view inside and when I resize the NSScrollView, the height grows and it scrolls upward. Unless there is an easier way, I'll probably have to register a notification to see if the view changes size and then adjust the scrollPoint: to a new point. I'm having trouble getting method to work smoothly.
Thanks!
This question comes up from time to time, because it's not obvious.
The content will pin to the top left if [contentView isFlipped] == YES.