Re: Infinite Scroll View?
Re: Infinite Scroll View?
- Subject: Re: Infinite Scroll View?
- From: Kyle Sluder <email@hidden>
- Date: Tue, 08 Oct 2013 00:56:37 -0700
> On Oct 8, 2013, at 12:44 AM, Dave <email@hidden> wrote:
>
> Thanks Kyle,
>
> That's what I was trying to figure out, whether I needed to re-layout the views based on the positions or whether I could just do it by keeping an Array of the image views separately and rotating this as it scroll past the end. I sort of got this working, but of course the Subviews of the Scroll View just grows and grows!
>
> This is what I got at the moment:
>
> // Scroll past last item detected (in the scrollViewDidScroll delegate method)
>
> if (theScrollView.contentSize.width - theScrollView.contentOffset.x <= 1024)
> {
> myContentInfo = [self.pContentArray objectAtIndex:0];
> [self.pContentArray addObject:myContentInfo];
> [self.pContentArray removeObjectAtIndex:0];
>
> [self addContentInfo:myContentInfo withEndFlag:YES];
> }
>
> Which kind of works, but obviously isn't the way to do it.
>
> Thanks for confirming I needed to use -layoutSubviews, I'm about to start on this track now.
You don’t *have* to use -layoutSubviews, but you'll probably get the best results if you do. You could theoretically do this all in the delegate's implementation of -scrollViewDidScroll:, but that’ll probably double the number of layout passes and certainly multiply the number of message sends. When scrolling, you want to avoid as much unnecessary work as is reasonable.
It’s kind of a bummer that you’re going to need to split your logic up between the scroll view and its delegate, thus tightly coupling the two. I wish the frameworks exposed many more of their delegate hooks as subclass hooks as well. Scroll views seem to stir this desire particularly frequently.
--Kyle Sluder
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden