How to Pinch/Zoom in a UiWebView vertically only not horizontally - iphone

I want to make my webview to be pinched/zoomed vertically only. By zooming the webview I want to make it zommed vertically only but not horizontally.
Does it possible?

UIWebView also has UIScrollView as its subclass.
So refer how-to-lock-the-horizontal-scrolling-of-a-scrollview-in-ios link.

With a quick search, I found others that have blazed the trail before you:
Custom Pinch Zoom
The short answer is No, you can't realistically make an entirely custom pinch zoom like you would like. But, you can easily get the end behavior that you are looking for by manually rescaling your content after the automated pinch zoom has been released. It's not as pretty, but if your determined to have a vertical zoom, it might be the best option.

Related

Android zoomable constraintLayout

I'm new in android and have some questions. The idea is to simulate a book page with some images and text on it and animations that zoom on a column and after clicking a button zooms on a different part of page and so on. I have seen some good libraries for imageView pinch zoom and pan like PhotoView and Subsampling image scale by davemorrissey. I want pinch zoom and pan functionality on entire constraintLayout and all its child views including textViews not just an imageView. I also have seen zoomLayout library but apparently it have some problem with constraintLayout as a child.
Is there any solution to use the lovely subsampling library for this purpose? if no, where i have to look? any suggestion will be appreciated.
thanks
After searching a bit, I found this library called "GestureViews" by alexvasilkov. it supports constraintLayout and animations!
https://github.com/alexvasilkov/GestureViews

finding out vertical pinch out in UIPinchgestureRecogniser?

I want to increase width of UIView,when pinching out horizontally and also height only when pinching out vertically? is it possible in UIPinchGestureRecogniser?
Not directly possible but if you were to maintain state yes. You can get the touch points using locationOfTouch:inView. Track them as he pinches and see which direction they are in. Update accordingly.

UIScrollView Vertical Pan Snapping to top or bottom of view

I have an image that is 320x480 and upon orientation change this image obviously hangs out of view. There are some images where the focal point of it sits with it's bottom cut off (which isn't undesirable). My issue however is when the user pans vertically to see the full image, the view appears to snap to the bottom meaning the top of the focal point is cutoff. What I wish to happen is that the users can "free-scroll" through the image and perhaps move the images so the focal point is centre screen, instead of cutting off the top and bottom. I understand this is a difficult concept to describe in words so I've attached some images below.
This is how it starts:
This is where it snaps to the bottom:
This is the kind of view I wish to have but cannot:
Is there a way to control this "snapping" or perhaps a method I could use to override it when dealing specifically with this kind of orientation? My issue is that i WANT it to snap when panning left/right onto the other images in the ScrollView, just not up/down.
EDIT:
pagingEnabled is the property that controls this snapping, but is there anyway to detect if the movement is Up/Down or Left/Right and disable or enable this property in each occasion?
Cheers for any help you can offer
You can try using two nested scroll views; one is limited to scrolling horizontally with paging enabled, and one (or one for each page if you're displaying several images?) limited to scrolling vertically with paging disabled. By default this will work like you said, paging/snapping horizontally but free scroll vertically. However, it will only let you scroll in one direction at a time (either horizontally or vertically, not diagonally).
If you want to use nested scroll views like this but you'd like to allow scrolling/dragging in both directions simultaneously, take a look at my solution for this: Nested UIScrollViews scrolling simultaneously

Really, really big UIScrollViews

I'm trying to make a level-of-detail line chart, where the user can zoom in/out horizontally by using two fingers, and grow the contentSize attribute of the the UIScrollView field. They can also scroll horizontally to shift left or right and see more of the chart (check any stock on Google Finance charts to get an idea of what I'm talking about). Potentially, the scroll view could grow to up to 100x its original size, as the user is zooming in.
My questions are:
- Has anyone had any experience with UIScrollViews that have such large contentSize restrictions? Will it work?
- The view for the scroll view could potentially be really huge, since the user is zooming in. How is this handled in memory?
- Just a thought, but would it be possible to use UITableViewCells, oriented to scroll horizontally, to page in/out the data?
This is kind of an open ended question right now - I'm still brainstorming myself. If anyone has any ideas or has implemented such a thing before, please respond with your experience. Thanks!
This is quite an old topic, but still I want to share some my experiences.
Using such a large UIView (100x than its origin size) in UIScrollView could cause Memory Warning. You should avoid render the entire UIView at once.
A better way to implement this is to render the only area which you can see and the area just around it. So, UIViewScroll can scroll within this area smoothly. But what if user scrolled out of the area that has been rendered? Use delegate to get notified when user scroll out of the pre-rendered area and try to render the new area which is going to be showed.
The basic idea under this implementation is to use 9 UIViews (or more) to tile a bigger area, when user scrolled (or moved) from old position to new position. Just move some UIViews to new place to make sure that one of UIView is the main view which you can see mostly, and other 8 UIViews are just around it.
Hope it is useful.
I have something similar, although probably not to the size your talking about. The UIScrollView isn't a problem. The problem is that if you're drawing UIViews on it (rather than drawing lines yourself) UIViews that are well, well off the screen continue to exist in memory. If you're actually drawing the lines by creating your own UIView and responding to drawRect, it's fine.
Assuming that you're a reasonably experienced programmer, getting a big scroll view working that draws pars of the chart is only a days work, so my recommendation would be to create a prototype for it, and run the prototype under the object allocations tool and see if that indicates any problems.
Sorry for the vagueness of my answer; it's a brainstorming question
But still, this approach (in the example above) is not good enough in some cases. Cause we only rendered a limited area in the UIScrollView.
User can use different gestures in UIScrollView: drag or fling. With drag, the pre-rendered 8 small UIViews is enough for covering the scrolling area in most of the case. But with flinging, UIScrollView could scroll over a very large area when user made a quick movement, and this area is totally blank (cause we didn't render it) while scrolling. Even we can display the right content after the UIScrollView stops scrolling, the blank during scrolling isn't very UI friendly to user.
For some apps, this is Ok, for example Google map. Since the data couldn't be downloaded immediately. Waiting before downloading is reasonable.
But if the data is local, we should eliminate this blank area as possible as we can. So, pre-render the area that is going to be scrolled is crucial. Unlike UITableView, UIScrollView doesn't have the ability to tell us which cell is going to be displayed and which cell is going to be recycled. So, we have to do it ourselves. Method [UIScrollViewDelegate scrollViewWillEndDragging:withVelocity:targetContentOffset:] will be called when UIScrollView starts to decelerating (actually, scrollViewWillBeginDecelerating is the method been called before decelerating, but in this method we don't know the information about what content will be displayed or scrolled). So based on the UIScrollView.contentOffset.x and parameter targetContentOffset, we can know exactly where the UIScrollView starts and where the UIScrollView will stop, then pre-render this area to makes the scrolling more smoothly.

How to code smooth scrolling for "flick" gesture on iPhone

I have horizontal list for which I'm implementing my own scrolling logic. I have the "touch and drag" scrolling working great, but I'm having trouble with the "flick" gesture. All the built in scrollable views have the feature that if you "flick" the view it scrolls faster or slower based on the intensity of the flick.
Does anyone has any suggestion how do that for my view?
What I'm doing right now is changing the UIView.center.x coordinate of my custom UIView to scroll it across the screen
I would strongly suggest you figure out how to make use of the built in UIScrollView class. Apple has invested a LOT of effort to make scrolling feel 'right'. You may be able to recreate some, or even all, of that feel, but it'll take a lot of work. Better to piggy back off of what's already been done.
If you want to implement your own scroll view, you'll have to make the view scroll based on the length of the sweeping distance and the speed at witch it went across the screen. Taking these parameters as input and using simple geometry math you could calculate how much further the view should scroll after the sweep has ended(touchesEnded event).
Ofcourse this is not as simple as it sounds, making the flick gesture just feel right and natural is much harder.
If you really are set on doing this yourself, Drew McCormack has a great article on MacResearch where he explains some of the physics behind momentum-based scrolling. His implementation uses HTML, CSS, and JavaScript, but the core principles could be brought across to your custom UIView subclass.