Due to some requirements I'm zomming subview of UIScrollView with UIPinchGestureRecognizer and not using UIScrollView's default zooming. In selector of gesture I resize my subview with a factor and reset contentSize of UIScrollView. It's working perfectly. The problem is that when I resize the frame of subview then it's increased or decreased in one direction. I want it to zoomin/zoomout on touched point like in a UIScrollView or in Gallery of iOS. How can I achieve this?
Related
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.
I have scrollview and on top of it there is a uiview, what I want to do is when i scroll scrollview then top uiview should also get scrolled accordingly. I don't want to put that uiview inside the scrollview due to some reason . but how to make it scrollable even though it is not inside the scrollview.
If you want another view to scroll, it should also be a UIScrollView or a class which inherits it. The UIView itself is not scrollable.
Thus, you could link you background scroll view contentOffset to your front scroll view.
Anyways, your restrictions are strange. If you could be more explicit, someone might provide you a more usefull/simple method to achieve your tasks.
You can listen to the scrollView's contentOffset with KVO, and update your upper UIView's transform accordingly.
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.
How can i zoom a UIView without using UIScrollBar? I can add pinch gesture recognizer but how can i move the zoomed image to selected area?
What prevents you from using UIScrollView? It is probably the most easy way to handle zooming and scrolling.
If UIScrollView is not allowed. You can probably add pinch and pan gesture recognizer and implement their delegates for zooming and scrolling.
Please check this..
Image-manipulation-with-uigesturerecognizer
Here is Sample Project
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.