How to turn off diagonal scrolling but still be able to scroll horizontally and vertically

I have a problem with scroll view. I can scroll up and down to the left, but sometimes the scroll view decides to pan diagonally. Directional lock is on and for some reason it doesn't help. Actually I finally came up with a way to fix this, now when I scroll to the right or left (FYI: I have paging enabled) the current page before it moves glitches and scrolls to the top, because I set the content height to 0 when contentOffset.x becomes> than 1. Is there a way to fix this or come to it from a different angle? Please help! Heres my "semi-success" if you ..

// MARK: Scroll view delegate methods
func scrollViewDidScroll(scrollView: UIScrollView) {
    self.scrollView.contentSize.height = 1000
    self.scrollView.contentSize.width = scrollView.bounds.width * 2
    self.scrollView.bounces = false
    if self.scrollView.contentOffset.x > 1 {
        self.scrollView.pagingEnabled = true
        self.scrollView.contentSize.width = scrollView.bounds.width * 2
        self.scrollView.contentSize.height = 0
    }
    if self.scrollView.contentOffset.y > 1 {
        self.scrollView.pagingEnabled = false
    }
    if self.scrollView.contentOffset.x >= self.scrollView.frame.width {
            self.pageController.currentPage = 1
    }
    else {
        self.pageController.currentPage = 0
        self.scrollView.contentSize.height = 1000
        self.scrollView.scrollsToTop = false
    }
}

      

+3
ios swift xcode6 uiscrollview


source to share


No one has answered this question yet

See similar questions:

83
UIScrollView: horizontal scrolling, vertical scrolling?
1
Disable diagonal drag in UIScrollview

or similar:

1172
How can I disable the selection of a UITableView?
25
How can I know exactly when the UIScrollView has stopped scrolling?
4
Unable to scroll vertically UIScrollView / UITableView ChildViewController if UIScrollView scrolling of parent class is forced off
4
ios UIScrollview skips scroll event to view
4
vertical UIScrollView inside horizontal UIPageViewController not scrolling
2
How to stop scrolling uiscrollview when user stops touching screen
2
Horizontal UISwipeGestureRecognizer in UIScrollView sub? (UIScrollView only requires vertical scrolling)
1
Vertical UIScrollView over horizontal UIScrollView
0
How to make UIScrollView inside UIScrollView activity at the same time
0
UIScrollView strategies for horizontal and vertical scrolling



All Articles
Loading...
X
Show
Funny
Dev
Pics