UIScrollView auto scrolls to bottom during change to landscape orientation - cocoa-touch

I have a scrollview with 2 UITextViews (neither are editable). When a change to landscape orientation occurs, the scollview inexplicably scrolls to the bottom. This behaviour does not occur when rotating to portrait. I have tried setting the scrollEnabled property before rotation to NO, but to no avail. Any help would be appreciated please.

I eventually found that by setting the scrollview contentsize to 0 before rotation and restoring it during or after rotation prevents this unwanted auto scrolling

Related

Height of my UIScrollView portrait and landscape

Good morning,
I'm working with UIScrollView for the first time and I'm trying to make the height of the scroll as I have elements in my screen. In my attempt I can scroll through my View, but when I'm in portrait mode I have a lot of scroll and when I'm in landscape mode I have the exact scroll that I would have.
How can I make the scroll showing only my content? Because at the moment I set a height and the scroll is showing too much height in my portrait mode.
I will appreciate any help, because I have search some questions but I can't really go on with my project without that.
Thanks in advance.

UIScrollView Failing to Scroll

I have a UIScrollView with a fair bit of content in it. The structure is shown below:
However, my scrollview isn't allowing a scroll to occur. I have made sure AutoLayout is off and the scrollview is larger than the screen size. The ScrollView isn't altered in the .h or .m files in any way. Any ideas why it may not be scrolling? The settings are default for the scrollview (essentially dragged and dropped in IB). ScrollView sizes as below
Your UIScrollView should be equal to or smaller than your screen. The content of your scroll view should be larger than your scroll view's frame. (It is the content of the scroll view that scrolls within the bounds of the scroll view's frame.)
Then, in code, do something like this:
[scrollView setContentSize:CGSizeMake(contentWidth, contentHeight)];
[scrollView setScrollEnabled:TRUE];
The scrollView should (typically) NOT be larger than your screen size.
It's NOT the scrollView that scrolls, it's the content IN the scrollView that scrolls.
So set the contentSize of your scrollView to the appropriate size of your content and keep the scrollView itself within the bounds of the screen.

Adding UIPinchGestureRecognizer on a UIScrollview's subview

I'm adding a view as a UIScrollview's subview. This subview determines the contentsize of scrollview. On this view I add a UIPinchGesture and in selector target method of gesture i resize the view and reset contentsize of scrollview. BTW I earlier tried zooming of scrollview but it didn't fulfilled my requirement so I did it with UIPinchGesture. My problem is that normally the content size of scrollview is greater than it's frame so scrolling is enabled. When I try to pinch with two fingers the scrollview's scrolling is triggered and Pinchgesture seldomly recognized. I can't disable scrolling of UIScrollview as this is one of my requirement. Can anybody help me to solve this problem.
Set delayContentTouches property of UIScrollView to NO (instead of the default YES). This will allow the touch to propagate to the subviews of the scroll view immediately.

ScrollView not working in iPad simulator?

First off, how do you test scrolling in the iPad simulator? I have a touch pad and I've tried dragging two fingers and I've tried click & dragging two fingers, but I can't get it to scroll. Am I doing that part correctly?
Assuming that I'm testing properly, why won't my scrollview scroll? I have a basic view controller in my storyboard and I dragged a scrollview into it. I made an outlet from it into my code and then in my code I generate a bunch of buttons and add them to this scrollview. They get displayed properly. Am I missing something?
set scrollview content size such
[MyScrollView setContentSize:CGSizeMake(320, 500)];
this is for iPhone for example.
You can also make two fingers by press the alt key next to cmd in mac
HOLD PRESS alt + mouse move on simulator
set contentsize of the scrollview,to enable scroll.
Detailed explanation
https://developer.apple.com/library/ios/#documentation/WindowsViews/Conceptual/UIScrollView_pg/CreatingBasicScrollViews/CreatingBasicScrollViews.html
You have to define the contentSize of scrollView which is generally bigger in frame than parentview or its frame to make it scrollable.
[viw setContentSize:CGRectMake(width,height)];
set it in viewDidLoad or where You alloc srollview.

content offset for UIScrollView does not change while rotating and scrolling simultaneously

I have a UIScrollView with paging enabled.
Each page is of width 768.0px in portrait mode and 1024.0px in landscape mode.
If I am in the second page in the portrait mode, then the content offset for the UIScrollView is 768.0.
However, if I scroll to the next page and rotate the device to landscape at the same time, the content offset does not update and remains at 768.0 instead of the expected content offset 2048.0, giving wrong results.
Any idea on how i can invoke the scrollViewDidEndDecelerating: with the updated values?
Thanks in advance!
Check the rotation delegate methods for view controller which manages the scroll view. I'd suggest disabling user interaction while rotation is in progress (with willRotate... and didRotate... delegate methods) since you're doing frame resizing for scroll view and it's subviews.