UA-17470720-3

Jump to content


Photo
* - - - - 2 votes

Handling UIScrollViewDelegate methods


  • Please log in to reply
8 replies to this topic

#1 Tommy Wild

Tommy Wild

    Advanced Member

  • STV 3.0 Pro
  • PipPipPipPipPip
  • 175 posts
Reputation: 12
Good

Posted 21 April 2011 - 09:05 AM

Is there a way to get these delegate methods to be called when using STV? If I set self.tableView.delegate = self, they get called, but of course it screws up everything else :)

I have conformed to the UITableViewDelegate and UIScrollViewDelegate protocols, but no-go.

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView

#2 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 21 April 2011 - 09:44 PM

Hi Tommy,

We can definitely add these to SCTableViewModelDelegate. Would you mind giving me an idea of what you're trying to achieve? (is this some kind of pull-to-refresh implementation?)

#3 Tommy Wild

Tommy Wild

    Advanced Member

  • STV 3.0 Pro
  • PipPipPipPipPip
  • 175 posts
Reputation: 12
Good

Posted 21 April 2011 - 09:48 PM

Thanks Tarek :)

I am "lazy loading" images on cells.

#pragma mark -
#pragma mark Deferred image loading (UIScrollViewDelegate)
// Load images for all onscreen rows when scrolling is finished
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
	[super scrollViewDidEndDragging:scrollView willDecelerate:decelerate];
	
	if (!decelerate)
	{
		[self loadAvatarsForOnscreenRows];
	}
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
	
	[self loadAvatarsForOnscreenRows];
}


#4 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 23 April 2011 - 10:51 AM

Hi Tommy,

How about if we add a new delegate method called something like "tableViewModel:lazyLoadCell:forRowAtIndexPath:"?

#5 Tommy Wild

Tommy Wild

    Advanced Member

  • STV 3.0 Pro
  • PipPipPipPipPip
  • 175 posts
Reputation: 12
Good

Posted 25 April 2011 - 04:36 PM

Hi Tommy,

How about if we add a new delegate method called something like "tableViewModel:lazyLoadCell:forRowAtIndexPath:"?


When would that delgate method be called?

#6 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 26 April 2011 - 09:48 AM

Hi Tommy,

The delegate method will be called when appropriate for lazy loading cells (e.g. in scrollViewDidEndDragging & scrollViewDidEndDecelerating as per Apple recommendation, and as you did above in your code).

#7 Tommy Wild

Tommy Wild

    Advanced Member

  • STV 3.0 Pro
  • PipPipPipPipPip
  • 175 posts
Reputation: 12
Good

Posted 26 April 2011 - 10:38 PM

The "decelerate" variable is important, however.

#8 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 26 April 2011 - 10:47 PM

Sure, STV will take care of all that :)

#9 Tommy Wild

Tommy Wild

    Advanced Member

  • STV 3.0 Pro
  • PipPipPipPipPip
  • 175 posts
Reputation: 12
Good

Posted 26 April 2011 - 10:53 PM

awesome as usual, Tarek.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users