UIScrollView delegate methods not calling properly

To scroll up and down, I need to call two methods for this, I used the method below. I am using scrollview delegation method for UICollection , as it is a preview for UIScrollView . Here is the code I wrote, but the scroll is not so easy to navigate, and the result is also inaccurate for some time, can anyone suggest.

 - (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView{ CGPoint mScrollPosition = [scrollView.panGestureRecognizer velocityInView:mCollectionView]; if (mScrollPosition.y > 0.0f){ NSLog(@"going down"); //Action One mYearHeaderTitle--; [self.mCollectionView reloadData]; } else if (mScrollPosition.y < 0.0f){ NSLog(@"going up"); //Action two mYearHeaderTitle++; [self.mCollectionView reloadData]; } } 
+4
source share
6 answers

Using:

  • - (void)scrollViewDidScroll:(UIScrollView *)scrollView
  • - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView

Instead of this:

 - (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView 
+2
source

Use the following methods:

  - (void)scrollViewDidScroll:(UIScrollView *)scrollView - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView 

Connect the delegate to view the scroll by right-clicking on the scroll view and connect to the delegation method to the file owner (Or)

 scrollview.delegate = self; 
+2
source

You can try setting self.scrollView.delegate to an object that should act as a delegate for scrollView.

0
source

Set up view controller as <UIScrollViewDelegate>

0
source

** Use this: **

  //MARK: - UIScrollview Delegate - func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) { if scrollView.contentOffset.y > 0 { if (tableView.contentSize.height - (tableView.contentOffset.y + scrollView.bounds.size.height)) == 0 { self.count += 1 let strCount = String(self.count) let params:[String:String] = ["search":SAFESTRING(str: self.strSearchVal!),"page":strCount,"length":"25"] let url = API_USER.BASE_URL + API_USER.SEARCH_LISTING self.callGetEventlist(url: url, params: params) } else { } } } 
0
source

In my case, I had to make my view both a delegate for UITextViewDelegate and UIScrollViewDelegate. This will not call the method until I add both. Probably because I'm in EAGLView, not in the viewcontroller.

 @interface EAGLView : UIView <UITextFieldDelegate, SDWebImageManagerDelegate, UITextViewDelegate, UIScrollViewDelegate> 

I also did:

 alertMessage.delegate = self; 

As alertMessage is my TextView, which I use as a scroller of terms of service.

-one
source

Source: https://habr.com/ru/post/1495316/


All Articles