Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to let UIScrollView invoke scrollViewDidScroll, when contentSize is decreased
    primarykey
    data
    text
    <p>I have a dynamic UITableView, which will insert and delete rows when clicking button.</p> <pre><code>-(IBAction)foldingClicked:(id)sender { self.isInfoFolded = !self.isInfoFolded; if( self.isInfoFolded) { //self.mainTable remove rows }else { //self.mainTable insert rows } } </code></pre> <p>and I did some animation in <code>scrollViewDidScroll:</code></p> <pre><code>-(void)scrollViewDidScroll:(UIScrollView*)scrollView { CGFloat main_offset = scrollView.contentOffset.y; //animation CGRect image_frame = self.imageView.frame; if((main_offset &gt;= 0 ) &amp;&amp; (main_offset &lt;= self.imageView.frame.size.height)) { image_frame.origin.y = main_offset/2; }else { image_frame.origin.y = image_frame.size.height/2; } } </code></pre> <p>It mostly works fine. But when I </p> <ol> <li>click button to insert rows. ( the tableView contentSize increase )</li> <li>Scroll table view to a big offset.</li> <li>click button to delete rows. ( the tableView contentSize decrease )</li> </ol> <p>Result: The table view will scroll up because the decreased <code>contentSize</code> is making the valid <code>contentOffset</code> smaller too, during which process my <code>scrollViewDidScroll</code> method is not invoked, that makes the animation incomplete, and leaving <code>imageView</code> at wrong position in my case.</p> <p>I tried calling <code>scrollViewDidScroll:</code> right after removing rows. However <code>scrollViewDidScroll:</code> is invoked only once and the contentOffset is '0' in that execute. It's not gradually down to '0' . So is there any way for making <code>scrollViewDidScroll</code> being called continuously like it usually do? </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload