Is there a way to make something truly free scrolling div (any direction) on iOs webview - ios

I want a div that can be dragged any direction and is about 4x width and 4x height of the screen.
I set the body height and width, and you can scroll it diagonally some of the time, but other times when you go to scroll it will go only straight vertically or straight horizontally. It seems to be when you start scrolling straight up, it sticks that way. Is this normal for scrolling in an oversized webview div, or is there something else that might explain this?
This is on an iPad, with a body set to width:4000px and height:3000px.

The iPhone's tendency to scroll exactly horizontally or exactly vertically is intentional, and it's usually a useful feature: if you're reading a tall column of text that could scroll horizontally, it's nice to be able to scroll down without worrying about accidentally moving the view from side to side as you go. As far as I'm aware there's no way to turn this behavior off.

there is a property name directionalLockEnabled that get a bool
in scrollView class.
this will do the trick:
theWebView.scrollView.directionalLockEnabled = NO;

Related

Quick scroll by touching scroll indicator in UITextView

I'm trying to create the effect seen in some iOS apps where swiping the screen scrolls the ScollView/TextView normally, but sliding on the far right (where the scroll indicator is) creates a quick scrolling effect that allows the user to scroll through the position in the overall length of the view. For example, sliding on the far right from the middle of the screen to the bottom would take the TextView from the middle of its content to the very end.
Is there any pre-established way to do this, or is this an effect I would have to create from scratch?
Thanks a lot for any help, and I'm sorry if this question wasn't very clear.

iOS UIScrollView with multiple pages visible

I'm having a little issue with scrollview pagination.
My intention is to have 3 pages visible on screen and when I scroll right only on page is scrolled, following the example below, scrolling right will display page 2, 3 and 4 on screen:
However I don't know how to display mutiple pages at the same time, at the moment I have it like this:
Obviously like this is not what I want.
To achieve the desired functionality I tried making the scrollview's frame the size of the page I want (1/3 of the screen width) and setting the clipToBound to NO so the other pages are visible. This indeed shows 3 pages in the screen; however since the scrollview frame is only 1/3 of the screen I can only swipe in that area, I would like the swipe area to be the whole screen width.
You're on the right path. Now you can try manipulating UIPanGestureRecognizer of your scrollView, say, re-attaching it to scrollView's superview.
Alternatively, take a look at iCarousel, it can be perfectly customized to suit your needs.
My solution in the end was the following:
I took my initial approach.
I disabled the scrollview's scrollEnabled property.
Added swipe gesture recognisers to the scrollview.
When the gesture is made I modify the scrollview's contentOffset to move 320/3 pixels to the right or left.

UIWebView contentInset without extra height at bottom

I'm creating a view controller that uses a web view which slides behind the navigation bar and status bar. To do this, I'm setting the webView.scrollView.contentInset property to have a top inset of 64.
However, this doesn't shrink the amount of area the web view wants to take up, so if a page is less than a screenful, it has 64 px of white space at the bottom to scroll through. The web views are in a vertical UIPageViewController, so this disrupts paging. Is there some way to get rid of this extra space?
Have you tried something like adjusting the webview's scrollview content insets? Example:
webView.scrollView.contentInset = UIEdgeInsetsMake(0, 0,64, 0)
It sounds like what you need is to adjust the webView.scrollView.contentSize and adjust the height by 64. You may need to provide more information about how it slides behind the nav bar and status bar to help me answer this. I would take a look at this section of the Scroll View Programming Guide:
http://developer.apple.com/library/ios/#documentation/WindowsViews/Conceptual/UIScrollView_pg/CreatingBasicScrollViews/CreatingBasicScrollViews.html
Change the clipsToBounds.
webView.clipsToBounds = NO;
This will make its content visible outside its frame, so set its frame like normal, right under the navigation bar. The navigation bar will be translucent and you will see its content under it.
Don't forget to disable Autolayout for the web view!
I've sort of made an end-run around this problem by disabling scrolling on short pages. Basically, I use -stringByEvaluatingJavaScriptFromString: to run some JavaScript inside the page that walks down from document.body and computes the position of the bottom of the bottommost element. (document.body itself is always at least as large as the viewport, so I can't look at its size.) Then, back in Objective-C-land, I compare that to the height of the web view (less the inset), and if it's less, I disable scrolling. This is not a perfect solution, but it covers the worst symptoms.
If someone can come up with a better solution than this, I'd love to hear about it! Either way, I can't award the bounty to myself, so someone will be getting it.

How to create UIScrollView with different page sizes (page snapping, bounce)

I'm trying to create custom vertical UIScrollView which could handle multiple pages with different page heights.
Assumptions:
page height is equal or greater than screen height
if page is taller than screen height, it scrolls as usual UIScrollView – with bouncing on top and bottom
if user ends up scrolling and "page break" is in the middle of screen
if there is no velocity - page snaps to closest
if there is velocity - page changes to one in direction of swipe
I've tried many approaches to achieve this, but I've stumbled upon many UIScrollView quirks, which make it hard.
Problems:
UIPanGestureRecognizer has unreliable method for getting velocity (velocityInView:)
scrollViewWillEndDragging:withVelocity:targetContentOffset: method gives me headache, because it arbitrarily can destroy my attempts to animate setting content offset
I don't know how to achieve bounce in one of the middle pages, I'm afraid i would have to rewrite whole scrolling handling
when I try to override setting content offset when UIScrollView is decelerating, what I get is
my content offset is set
deceleration continues beyond content offset I set
Bonus
I have also tried putting UIScrollView inside UIScrollView as a page, but this approach was also pain in the neck. For example when I was at the bottom of inside scroll, then i scrolled down a bit, put my finger away and quickly grabbed again and scrolled upwards, the outer scroll received touch, which messed up inside scroll presentation.
Does somebody have any idea how to do this? Any tips will be helpful as I'm completely stuck...
Try this. Might help. Based on the Circa news app.
https://www.cocoacontrols.com/controls/rscircapagecontrol

AS3: Increase size of scroll bar

This my be a really simple question but I have googled so hard looking for an answer. I have a datagrid which displays a long list of information. Its an iOS app so the input is touch and the scroll bar is tiny. How can I increase its size for easier use?
Thanks =)
Feathers is as3 solution to mobile ui : http://feathersui.com
These scrollbars can be targeted by DataGridInstance.verticalScrollBar and DataGridInstance.horizontalScrollBar. These are actually ScrollBar instances so you can use the .setSize() method or .width and .height setters to resize these.
However, the documentation indicates:
Note: If you use the setSize() method, you can change only the width of a horizontal scroll bar or the height of a vertical scroll bar. At the time of authoring you can set the height of a horizontal scroll bar or the width of a vertical scroll bar, but the values will be reset when the movie is published. Only the dimension of a scroll bar that corresponds to its length can be changed.
So I'm afraid it's not an option with the built-in component.
Use code like this:
dataGrid.scroller.verticalScrollBar.scaleX = 2;

Resources