Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing UIScrollVIew Content Inset triggers scrollViewDidScroll

I use the following code to set the contentInset for my tableView.

self.scrollView.contentInset = UIEdgeInsetsMake(109, 0, 44, 0);

But this triggers the UIScrollView delegate method scrollViewDidScroll:.

Is this the expected behaviour? If so, is there any workaround to avoid this situation?
Thanks in advance.

like image 947
GoGreen Avatar asked Sep 28 '22 10:09

GoGreen


1 Answers

You can try removing the scroll views delegate before setting the content insets. Then reapply the delegate.

id scrollDelegate = scrollView.delegate;
scrollView.delegate = nil;
scrollView.contentInset = UIEdgeInsetsMake(109, 0, 44, 0);
scrollView.delegate = scrollDelegate;
like image 109
Shanmugasundharam Avatar answered Nov 15 '22 06:11

Shanmugasundharam