Infinite Scroll View Revisited

2013-10-16 Thread Dave
Hi,

This has been bugging me for a while and today, I've managed to grab some time 
in order to try and get it working.

I based my class on the Street Scroller Sample App from Apple. The main 
methods that are important in Street Scroller are:


- (void)recenterIfNecessary
{
CGPoint currentOffset = [self contentOffset];
CGFloat contentWidth = [self contentSize].width;
CGFloat centerOffsetX = (contentWidth - [self bounds].size.width) / 2.0;
CGFloat distanceFromCenter = fabs(currentOffset.x - centerOffsetX);

if (distanceFromCenter  (contentWidth / 4.0))
{
self.contentOffset = CGPointMake(centerOffsetX, currentOffset.y);

// move content by the same amount so it appears to stay still
for (UILabel *label in self.visibleLabels) {
CGPoint center = [self.labelContainerView convertPoint:label.center 
toView:self];
center.x += (centerOffsetX - currentOffset.x);
label.center = [self convertPoint:center 
toView:self.labelContainerView];
}
}
}


- (void)tileLabelsFromMinX:(CGFloat)minimumVisibleX 
toMaxX:(CGFloat)maximumVisibleX
{
// the upcoming tiling logic depends on there already being at least one 
label in the visibleLabels array, so
// to kick off the tiling we need to make sure there's at least one label
if ([self.visibleLabels count] == 0)
{
[self placeNewLabelOnRight:minimumVisibleX];
}

// add labels that are missing on right side
UILabel *lastLabel = [self.visibleLabels lastObject];
CGFloat rightEdge = CGRectGetMaxX([lastLabel frame]);
while (rightEdge  maximumVisibleX)
{
rightEdge = [self placeNewLabelOnRight:rightEdge];
}

// add labels that are missing on left side
UILabel *firstLabel = self.visibleLabels[0];
CGFloat leftEdge = CGRectGetMinX([firstLabel frame]);
while (leftEdge  minimumVisibleX)
{
leftEdge = [self placeNewLabelOnLeft:leftEdge];
}

// remove labels that have fallen off right edge
lastLabel = [self.visibleLabels lastObject];
while ([lastLabel frame].origin.x  maximumVisibleX)
{
[lastLabel removeFromSuperview];
[self.visibleLabels removeLastObject];
lastLabel = [self.visibleLabels lastObject];
}

// remove labels that have fallen off left edge
firstLabel = self.visibleLabels[0];
while (CGRectGetMaxX([firstLabel frame])  minimumVisibleX)
{
[firstLabel removeFromSuperview];
[self.visibleLabels removeObjectAtIndex:0];
firstLabel = self.visibleLabels[0];
}
}

- (void)layoutSubviews
{
[super layoutSubviews];

[self recenterIfNecessary];
 
// tile content in visible bounds
CGRect visibleBounds = [self convertRect:[self bounds] 
toView:self.labelContainerView];
CGFloat minimumVisibleX = CGRectGetMinX(visibleBounds);
CGFloat maximumVisibleX = CGRectGetMaxX(visibleBounds);

[self tileLabelsFromMinX:minimumVisibleX toMaxX:maximumVisibleX];
}


I'm got to the stage where as far as I can see recenterIfNecessary just 
doesn't work correctly and I'm having difficulty trying to figure out what is 
actually supposed to do?

I am trying to scroll infinitely through the following images (these are Test 
Images so I can tell what is going on!), in the real app, these images will be 
downloaded. The height is fixed at 200 but the Width is Variable.

Index   File Name   ImageSize   XMin/XMax   

0   Image01.png 200,200 ,0199   
1   Image02.png 200,200 0200,0399   
2   Image03.png 410,200 0400,0809   
3   Image04.png 410,200 0810,1219
4   Image05.png 200,200 1220,1419
5   Image06.png 410,200 1420,1829
6   Image07.png 200,200 1830,2029
7   Image08.png 200,200 2030,2229
8   Image09.png 200,200 2230,2429

0/9 Image01.png 200,200 2430,2629   
Wrap Around back to 0.


Total Width of all Images:  2430
 
In my Class, if I comment out the  recenterIfNecessary call, all my Views get 
added correctly and are shown in the correct order, and I can scroll them to 
the end and it stops as expected.

With recenterIfNecessary enabled,  as soon you begin the scroll and it runs 
Frame Recalculation Loop, the Views go all over the place. So, I'm pretty sure 
that this method is wrong (or at least my implementation of it is wrong, when 
you take the rest of the code with it).

This the a dump of the Frame Rect for each view before and after the center has 
been set.


Before myFramgeRect: {{0, 0}, {200, 200}}
After myFramgeRect: {{703, 0}, {200, 200}}
Before myFramgeRect: {{200, 0}, {200, 200}}

Re: Infinite Scroll View?

2013-10-09 Thread Dave
Hi,

Got it working! The problem was partly due to tiredness and partly due to a 
misunderstanding about when layoutSubviews gets called.

If you look at the Street Scroller sample, you'll see that it has its content 
in-built, in fact it generate new content on the fly. The problem I had was 
that the content (images in this case) needed to be loaded externally from a 
URL or from a file. Once I figured out how to get the process going it was ok 
and I did it without having to add code to the delegate which is always a good 
thing.

Thanks a lot to everyone that helped.

All the Best
Dave

On 9 Oct 2013, at 00:07, Damian Carrillo damiancarri...@me.com wrote:

 Hi Dave,
 
 What about if you have some repetition of the images? Say the following is a 
 container UIView that has all of your UIImageViews stacked horizontally and 
 the width of the following view is far smaller than that of the UIScrollView 
 it's contained in. The gray areas are duplicated image views, and the the 
 white area is the true set of images.
 scroll.png
 
 Say that in the previous image, the leftmost person is the first logical 
 image in your set of data. In your viewDidLoad, you could set the 
 contentOffset to the position of the first Person (ie. the leftmost white 
 edge) with something like:
 
 - (void)viewDidLoad
 {
 CGFloat someXPos = CGRectGetWidth([pictures frame]) + 
 CGRectGetWidth([reticle frame]);
 [scrollView setContentOffset:someXPos];
 }
 
 Then, once the user breaches the threshold value that has duplicates (the 
 gray areas), you call the following:
 
 - (void)scrollViewDidScroll:(UIScrollView *)scrollView
 {
 [scrollView setContentOffset:someXPos animated:NO];
 }
 
 The intent is that the scroll view snaps the container UIView back to a 
 position that contains no duplicates. The view has duplicates to account for 
 the period of time between sampling of scroll events. Note that this 
 suggestion is assuming that the images are fairly small, so that loading them 
 all doesn't cause too much memory pressure (which is what I understood from 
 earlier messages).
 
 Damian
 
 On Oct 8, 2013, at 4:53 PM, Dave d...@looktowindward.com wrote:
 
 Hi,
 
 Yes, I took a look, but it's not what I want to do. I have a number of 
 variable width images, not fixed width and all the examples I've seen use 
 pagingEnabled and have a fixed width.
 
 Also the Street Scroller sample, just creates a label view on demand, which, 
 again isn't what I want. I have (say) 20 variable width images, so I want it 
 to scroll from image 1 to 20 and then back to 1. The samples doesn't do 
 anything like this.
 
 Thanks anyway,
 All the Best
 Dave
 

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Infinite Scroll View?

2013-10-08 Thread Dave

On 7 Oct 2013, at 19:54, Kyle Sluder k...@ksluder.com wrote:

 On Mon, Oct 7, 2013, at 09:21 AM, Dave wrote:
 Hi,
 
 I'd like to be able to Scroll Infinitely in a Scroll, e.g. when the
 scrolling is past the last item in the Scroll start displaying the first
 and when scrolling before the first item, starting displaying the last.
 The items in this case are UIImageViews and they have a fixed height and
 a variable width and no one image will be wider that the Scroll View
 itself. Also it needs to work with pagingEnables = NO, e.g. there will be
 more than one Image visible.
 
 I've playing around a bit and found a some sample code that sort of does
 it but it doesn't handle the wrapping the Images smoothly (is was written
 to have paging enabled). 
 
 My plan was/is to detect when the scrolling had hit before the
 first/after the last and to move the first Subview to the End or the Last
 one to the beginning, depending on the direction of movement, but at the
 moment, I can't seem to see a way of detecting these conditions.
 
 It seems fairly straightforward, if a little labor intensive, to figure
 out the width and placement of all your image views, override
 -layoutSubviews to position only the ones that are potentially visible,
 and implement
 -scrollViewWillEndDragging:withVelocity:targetContentOffset: to figure
 out where to end scrolling, based on the current velocity.
 
 --Kyle Sluder

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.

All the Best
Dave














___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Infinite Scroll View?

2013-10-08 Thread Kyle Sluder
 On Oct 8, 2013, at 12:44 AM, Dave d...@looktowindward.com 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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Infinite Scroll View?

2013-10-08 Thread Dave
Hi,

I finally managed to get back on this! I've got it working when scrolling from 
left to right and can detect when the user scrolls past the last item, however, 
I can't seem to find a way to detect when the user scrolls to before the first 
item. 

I get -0 for offset X

2013-10-08 20:18:20.607 LTWScrollTest1[17988:a0b] contentOffset: {-0, 0}

But that doesn't do me much good!

It seems to work quite nicely going left to right, but having difficulties 
figuring out how to make it work scrolling right to left.


Any idea greatly appreciated as I'm need to get this working for tomorrow 
morning!

Thanks a lot.

All the Best
Dave



On 8 Oct 2013, at 08:56, Kyle Sluder k...@ksluder.com wrote:

 On Oct 8, 2013, at 12:44 AM, Dave d...@looktowindward.com 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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Infinite Scroll View?

2013-10-08 Thread Steve Christensen
Does (scrollView.contentOffset.x = 0) not work? How are you testing for it now?


On Oct 8, 2013, at 12:20 PM, Dave d...@looktowindward.com wrote:

 Hi,
 
 I finally managed to get back on this! I've got it working when scrolling 
 from left to right and can detect when the user scrolls past the last item, 
 however, I can't seem to find a way to detect when the user scrolls to before 
 the first item. 
 
 I get -0 for offset X
 
 2013-10-08 20:18:20.607 LTWScrollTest1[17988:a0b] contentOffset: {-0, 0}
 
 But that doesn't do me much good!
 
 It seems to work quite nicely going left to right, but having difficulties 
 figuring out how to make it work scrolling right to left.
 
 
 Any idea greatly appreciated as I'm need to get this working for tomorrow 
 morning!
 
 Thanks a lot.
 
 All the Best
 Dave
 
 
 
 On 8 Oct 2013, at 08:56, Kyle Sluder k...@ksluder.com wrote:
 
 On Oct 8, 2013, at 12:44 AM, Dave d...@looktowindward.com 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 (Cocoa-dev@lists.apple.com)
 
 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:
 https://lists.apple.com/mailman/options/cocoa-dev/punster%40mac.com
 
 This email sent to puns...@mac.com


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Infinite Scroll View?

2013-10-08 Thread Dave
Well, it never goes less than -0 whatever that means so the  is redundant 
and 0 is a valid offset, I need to detect a scroll to *before* 0, which I never 
get.

Thanks
Dave

On 8 Oct 2013, at 21:26, Steve Christensen puns...@mac.com wrote:

 Does (scrollView.contentOffset.x = 0) not work? How are you testing for it 
 now?
 
 
 On Oct 8, 2013, at 12:20 PM, Dave d...@looktowindward.com wrote:
 
 Hi,
 
 I finally managed to get back on this! I've got it working when scrolling 
 from left to right and can detect when the user scrolls past the last item, 
 however, I can't seem to find a way to detect when the user scrolls to 
 before the first item. 
 
 I get -0 for offset X
 
 2013-10-08 20:18:20.607 LTWScrollTest1[17988:a0b] contentOffset: {-0, 0}
 
 But that doesn't do me much good!
 
 It seems to work quite nicely going left to right, but having difficulties 
 figuring out how to make it work scrolling right to left.
 
 
 Any idea greatly appreciated as I'm need to get this working for tomorrow 
 morning!
 
 Thanks a lot.
 
 All the Best
 Dave
 
 
 
 On 8 Oct 2013, at 08:56, Kyle Sluder k...@ksluder.com wrote:
 
 On Oct 8, 2013, at 12:44 AM, Dave d...@looktowindward.com 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 (Cocoa-dev@lists.apple.com)
 
 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:
 https://lists.apple.com/mailman/options/cocoa-dev/punster%40mac.com
 
 This email sent to puns...@mac.com
 


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Infinite Scroll View?

2013-10-08 Thread Dave
Hi,

Spoke too soon! 

I just can't seem to get my head around this. I can make it work, but I'm 
getting into an infinite loop because updating the scroll view is causing the 
delegates to fire again (AFAICT). I'm not sure what to put in layoutSubviews 
and what to put in the delegate methods. I'm beginning to think this just isn't 
possible with UIScrollView and wondering if I should burn a DTS Support Request 
on it.

This would be so easy if I just had the source to UIScrollView!

All the Best
Dave

On 8 Oct 2013, at 20:20, Dave d...@looktowindward.com wrote:

 Hi,
 
 I finally managed to get back on this! I've got it working when scrolling 
 from left to right and can detect when the user scrolls past the last item, 
 however, I can't seem to find a way to detect when the user scrolls to before 
 the first item. 
 
 I get -0 for offset X
 
 2013-10-08 20:18:20.607 LTWScrollTest1[17988:a0b] contentOffset: {-0, 0}
 
 But that doesn't do me much good!
 
 It seems to work quite nicely going left to right, but having difficulties 
 figuring out how to make it work scrolling right to left.
 
 
 Any idea greatly appreciated as I'm need to get this working for tomorrow 
 morning!
 
 Thanks a lot.
 
 All the Best
 Dave
 
 
 
 On 8 Oct 2013, at 08:56, Kyle Sluder k...@ksluder.com wrote:
 
 On Oct 8, 2013, at 12:44 AM, Dave d...@looktowindward.com 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 (Cocoa-dev@lists.apple.com)
 
 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:
 https://lists.apple.com/mailman/options/cocoa-dev/dave%40looktowindward.com
 
 This email sent to d...@looktowindward.com


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Infinite Scroll View?

2013-10-08 Thread Marcelo Alves
Did you check the StreetScroller sample? 
https://developer.apple.com/library/ios/samplecode/StreetScroller/Introduction/Intro.html#//apple_ref/doc/uid/DTS40011102
 it is the same code that was demonstrated in the WWDC 2011 I told you before. 

--
:: marcelo.alves 


 On 08/10/2013, at 17:30, Dave d...@looktowindward.com wrote:
 
 Hi,
 
 Spoke too soon! 
 
 I just can't seem to get my head around this. I can make it work, but I'm 
 getting into an infinite loop because updating the scroll view is causing the 
 delegates to fire again (AFAICT). I'm not sure what to put in layoutSubviews 
 and what to put in the delegate methods. I'm beginning to think this just 
 isn't possible with UIScrollView and wondering if I should burn a DTS Support 
 Request on it.
 
 This would be so easy if I just had the source to UIScrollView!
 
 All the Best
 Dave
 
 On 8 Oct 2013, at 20:20, Dave d...@looktowindward.com wrote:
 
 Hi,
 
 I finally managed to get back on this! I've got it working when scrolling 
 from left to right and can detect when the user scrolls past the last item, 
 however, I can't seem to find a way to detect when the user scrolls to 
 before the first item. 
 
 I get -0 for offset X
 
 2013-10-08 20:18:20.607 LTWScrollTest1[17988:a0b] contentOffset: {-0, 0}
 
 But that doesn't do me much good!
 
 It seems to work quite nicely going left to right, but having difficulties 
 figuring out how to make it work scrolling right to left.
 
 
 Any idea greatly appreciated as I'm need to get this working for tomorrow 
 morning!
 
 Thanks a lot.
 
 All the Best
 Dave
 
 
 
 On 8 Oct 2013, at 08:56, Kyle Sluder k...@ksluder.com wrote:
 
 On Oct 8, 2013, at 12:44 AM, Dave d...@looktowindward.com 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 (Cocoa-dev@lists.apple.com)
 
 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:
 https://lists.apple.com/mailman/options/cocoa-dev/dave%40looktowindward.com
 
 This email sent to d...@looktowindward.com
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 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:
 https://lists.apple.com/mailman/options/cocoa-dev/marcelo.alves%40me.com
 
 This email sent to marcelo.al...@me.com
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Infinite Scroll View?

2013-10-08 Thread Dave
Hi,

Yes, I took a look, but it's not what I want to do. I have a number of variable 
width images, not fixed width and all the examples I've seen use pagingEnabled 
and have a fixed width.

Also the Street Scroller sample, just creates a label view on demand, which, 
again isn't what I want. I have (say) 20 variable width images, so I want it to 
scroll from image 1 to 20 and then back to 1. The samples doesn't do anything 
like this.

Thanks anyway,
All the Best
Dave

On 8 Oct 2013, at 22:01, Marcelo Alves marcelo.al...@me.com wrote:

 Did you check the StreetScroller sample? 
 https://developer.apple.com/library/ios/samplecode/StreetScroller/Introduction/Intro.html#//apple_ref/doc/uid/DTS40011102
  it is the same code that was demonstrated in the WWDC 2011 I told you 
 before. 
 
 --
 :: marcelo.alves 
 
 
 On 08/10/2013, at 17:30, Dave d...@looktowindward.com wrote:
 
 Hi,
 
 Spoke too soon! 
 
 I just can't seem to get my head around this. I can make it work, but I'm 
 getting into an infinite loop because updating the scroll view is causing 
 the delegates to fire again (AFAICT). I'm not sure what to put in 
 layoutSubviews and what to put in the delegate methods. I'm beginning to 
 think this just isn't possible with UIScrollView and wondering if I should 
 burn a DTS Support Request on it.
 
 This would be so easy if I just had the source to UIScrollView!
 
 All the Best
 Dave
 
 On 8 Oct 2013, at 20:20, Dave d...@looktowindward.com wrote:
 
 Hi,
 
 I finally managed to get back on this! I've got it working when scrolling 
 from left to right and can detect when the user scrolls past the last item, 
 however, I can't seem to find a way to detect when the user scrolls to 
 before the first item. 
 
 I get -0 for offset X
 
 2013-10-08 20:18:20.607 LTWScrollTest1[17988:a0b] contentOffset: {-0, 0}
 
 But that doesn't do me much good!
 
 It seems to work quite nicely going left to right, but having difficulties 
 figuring out how to make it work scrolling right to left.
 
 
 Any idea greatly appreciated as I'm need to get this working for tomorrow 
 morning!
 
 Thanks a lot.
 
 All the Best
 Dave
 
 
 
 On 8 Oct 2013, at 08:56, Kyle Sluder k...@ksluder.com wrote:
 
 On Oct 8, 2013, at 12:44 AM, Dave d...@looktowindward.com 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 (Cocoa-dev@lists.apple.com)
 
 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:
 https://lists.apple.com/mailman/options/cocoa-dev/dave%40looktowindward.com
 
 This email sent to d...@looktowindward.com
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 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:
 https://lists.apple.com/mailman/options/cocoa-dev/marcelo.alves%40me.com
 
 This email sent to marcelo.al...@me.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com


Re: Infinite Scroll View?

2013-10-08 Thread Damian Carrillo
Hi Dave,

What about if you have some repetition of the images? Say the following is a 
container UIView that has all of your UIImageViews stacked horizontally and the 
width of the following view is far smaller than that of the UIScrollView it's 
contained in. The gray areas are duplicated image views, and the the white area 
is the true set of images.


Say that in the previous image, the leftmost person is the first logical image 
in your set of data. In your viewDidLoad, you could set the contentOffset to 
the position of the first Person (ie. the leftmost white edge) with something 
like:

- (void)viewDidLoad
{
CGFloat someXPos = CGRectGetWidth([pictures frame]) + 
CGRectGetWidth([reticle frame]);
[scrollView setContentOffset:someXPos];
}

Then, once the user breaches the threshold value that has duplicates (the gray 
areas), you call the following:

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
[scrollView setContentOffset:someXPos animated:NO];
}

The intent is that the scroll view snaps the container UIView back to a 
position that contains no duplicates. The view has duplicates to account for 
the period of time between sampling of scroll events. Note that this suggestion 
is assuming that the images are fairly small, so that loading them all doesn't 
cause too much memory pressure (which is what I understood from earlier 
messages).

Damian

On Oct 8, 2013, at 4:53 PM, Dave d...@looktowindward.com wrote:

 Hi,
 
 Yes, I took a look, but it's not what I want to do. I have a number of 
 variable width images, not fixed width and all the examples I've seen use 
 pagingEnabled and have a fixed width.
 
 Also the Street Scroller sample, just creates a label view on demand, which, 
 again isn't what I want. I have (say) 20 variable width images, so I want it 
 to scroll from image 1 to 20 and then back to 1. The samples doesn't do 
 anything like this.
 
 Thanks anyway,
 All the Best
 Dave



signature.asc
Description: Message signed with OpenPGP using GPGMail
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Infinite Scroll View?

2013-10-07 Thread Dave
Hi,

I'd like to be able to Scroll Infinitely in a Scroll, e.g. when the scrolling 
is past the last item in the Scroll start displaying the first and when 
scrolling before the first item, starting displaying the last. The items in 
this case are UIImageViews and they have a fixed height and a variable width 
and no one image will be wider that the Scroll View itself. Also it needs to 
work with pagingEnables = NO, e.g. there will be more than one Image visible.

I've playing around a bit and found a some sample code that sort of does it but 
it doesn't handle the wrapping the Images smoothly (is was written to have 
paging enabled). 

My plan was/is to detect when the scrolling had hit before the first/after the 
last and to move the first Subview to the End or the Last one to the beginning, 
depending on the direction of movement, but at the moment, I can't seem to see 
a way of detecting these conditions.

I logged contentOffset and contentSize in the scrollViewDidScroll delegate 
method and got these results:


scrollViewDidScroll Offset: {4017, 0}   - Size: {5119, 200}
scrollViewDidScroll Offset: {4061, 0}   - Size: {5119, 200}
scrollViewDidScroll Offset: {4095, 0}   - Size: {5119, 200}

When hitting the end and

scrollViewDidScroll Top Scroll View Offset: {106, 0}  - Size: {5119, 200}
scrollViewDidScroll Top Scroll View Offset: {24, 0}   - Size: {5119, 200}
scrollViewDidScroll Top Scroll View Offset: {-0, 0}   - Size: {5119, 200}

When hitting the start.

I'm not sure how if I can detect the start/end conditions using these values?

Any points on the best way to implement this would greatly appreciated!

All the Best
Dave

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Infinite Scroll View?

2013-10-07 Thread Marcelo Alves


There’s a WWDC video from 2011 : “Advanced ScrollView Techniques” which 
explains one way to do infinite scrolling. Look at 18:08 if it is what you want.


On 07/10/2013, at 13:21, Dave d...@looktowindward.com wrote:

 Hi,
 
 I'd like to be able to Scroll Infinitely in a Scroll, e.g. when the scrolling 
 is past the last item in the Scroll start displaying the first and when 
 scrolling before the first item, starting displaying the last. The items in 
 this case are UIImageViews and they have a fixed height and a variable width 
 and no one image will be wider that the Scroll View itself. Also it needs to 
 work with pagingEnables = NO, e.g. there will be more than one Image visible.
 
 I've playing around a bit and found a some sample code that sort of does it 
 but it doesn't handle the wrapping the Images smoothly (is was written to 
 have paging enabled). 
 
 My plan was/is to detect when the scrolling had hit before the first/after 
 the last and to move the first Subview to the End or the Last one to the 
 beginning, depending on the direction of movement, but at the moment, I can't 
 seem to see a way of detecting these conditions.
 
 I logged contentOffset and contentSize in the scrollViewDidScroll delegate 
 method and got these results:
 
 
 scrollViewDidScroll Offset: {4017, 0}   - Size: {5119, 200}
 scrollViewDidScroll Offset: {4061, 0}   - Size: {5119, 200}
 scrollViewDidScroll Offset: {4095, 0}   - Size: {5119, 200}
 
 When hitting the end and
 
 scrollViewDidScroll Top Scroll View Offset: {106, 0}  - Size: {5119, 200}
 scrollViewDidScroll Top Scroll View Offset: {24, 0}   - Size: {5119, 200}
 scrollViewDidScroll Top Scroll View Offset: {-0, 0}   - Size: {5119, 200}
 
 When hitting the start.
 
 I'm not sure how if I can detect the start/end conditions using these values?
 
 Any points on the best way to implement this would greatly appreciated!
 
 All the Best
 Dave
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 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:
 https://lists.apple.com/mailman/options/cocoa-dev/marcelo.alves%40me.com
 
 This email sent to marcelo.al...@me.com


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Infinite Scroll View?

2013-10-07 Thread Steve Christensen
Have you thought about representing your images as cells in a UITableView? If 
so, you could use something like BBTableView 
(https://github.com/bharath2020/UITableViewTricks). It's a subclass of 
UITableView lays out cells along an arc but it also has support for infinite 
scrolling, so you could just use the relevant pieces. Plus UITableView will 
handle putting the right image in the right vertical location, based on your 
data source.


On Oct 7, 2013, at 9:21 AM, Dave d...@looktowindward.com wrote:

 Hi,
 
 I'd like to be able to Scroll Infinitely in a Scroll, e.g. when the scrolling 
 is past the last item in the Scroll start displaying the first and when 
 scrolling before the first item, starting displaying the last. The items in 
 this case are UIImageViews and they have a fixed height and a variable width 
 and no one image will be wider that the Scroll View itself. Also it needs to 
 work with pagingEnables = NO, e.g. there will be more than one Image visible.
 
 I've playing around a bit and found a some sample code that sort of does it 
 but it doesn't handle the wrapping the Images smoothly (is was written to 
 have paging enabled). 
 
 My plan was/is to detect when the scrolling had hit before the first/after 
 the last and to move the first Subview to the End or the Last one to the 
 beginning, depending on the direction of movement, but at the moment, I can't 
 seem to see a way of detecting these conditions.
 
 I logged contentOffset and contentSize in the scrollViewDidScroll delegate 
 method and got these results:
 
 
 scrollViewDidScroll Offset: {4017, 0}   - Size: {5119, 200}
 scrollViewDidScroll Offset: {4061, 0}   - Size: {5119, 200}
 scrollViewDidScroll Offset: {4095, 0}   - Size: {5119, 200}
 
 When hitting the end and
 
 scrollViewDidScroll Top Scroll View Offset: {106, 0}  - Size: {5119, 200}
 scrollViewDidScroll Top Scroll View Offset: {24, 0}   - Size: {5119, 200}
 scrollViewDidScroll Top Scroll View Offset: {-0, 0}   - Size: {5119, 200}
 
 When hitting the start.
 
 I'm not sure how if I can detect the start/end conditions using these values?
 
 Any points on the best way to implement this would greatly appreciated!
 
 All the Best
 Dave


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Infinite Scroll View?

2013-10-07 Thread Dave
Hi,

I don't think that will work for me in this case as I need the images to be 
scrolled smoothly without gaps and AFAIK, using a table view cell will cause a 
gap - you can add a fragment of an image.

Thanks anyway
All the Best
Dave

On 7 Oct 2013, at 18:11, Steve Christensen puns...@mac.com wrote:

 Have you thought about representing your images as cells in a UITableView? If 
 so, you could use something like BBTableView 
 (https://github.com/bharath2020/UITableViewTricks). It's a subclass of 
 UITableView lays out cells along an arc but it also has support for infinite 
 scrolling, so you could just use the relevant pieces. Plus UITableView will 
 handle putting the right image in the right vertical location, based on your 
 data source.
 
 
 On Oct 7, 2013, at 9:21 AM, Dave d...@looktowindward.com wrote:
 
 Hi,
 
 I'd like to be able to Scroll Infinitely in a Scroll, e.g. when the 
 scrolling is past the last item in the Scroll start displaying the first and 
 when scrolling before the first item, starting displaying the last. The 
 items in this case are UIImageViews and they have a fixed height and a 
 variable width and no one image will be wider that the Scroll View itself. 
 Also it needs to work with pagingEnables = NO, e.g. there will be more than 
 one Image visible.
 
 I've playing around a bit and found a some sample code that sort of does it 
 but it doesn't handle the wrapping the Images smoothly (is was written to 
 have paging enabled). 
 
 My plan was/is to detect when the scrolling had hit before the first/after 
 the last and to move the first Subview to the End or the Last one to the 
 beginning, depending on the direction of movement, but at the moment, I 
 can't seem to see a way of detecting these conditions.
 
 I logged contentOffset and contentSize in the scrollViewDidScroll delegate 
 method and got these results:
 
 
 scrollViewDidScroll Offset: {4017, 0}   - Size: {5119, 200}
 scrollViewDidScroll Offset: {4061, 0}   - Size: {5119, 200}
 scrollViewDidScroll Offset: {4095, 0}   - Size: {5119, 200}
 
 When hitting the end and
 
 scrollViewDidScroll Top Scroll View Offset: {106, 0}  - Size: {5119, 200}
 scrollViewDidScroll Top Scroll View Offset: {24, 0}   - Size: {5119, 200}
 scrollViewDidScroll Top Scroll View Offset: {-0, 0}   - Size: {5119, 200}
 
 When hitting the start.
 
 I'm not sure how if I can detect the start/end conditions using these values?
 
 Any points on the best way to implement this would greatly appreciated!
 
 All the Best
 Dave
 


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Infinite Scroll View?

2013-10-07 Thread Steve Christensen
Does it not work to set the row height to the height of each of the images and 
then use a custom UITableViewCell that contains a UIImageView that fills the 
cell? The other benefit is that you don't have to have more images in memory 
than are visible within the table view's frame. (This may not be an issue if 
there aren't that many, of course.)


On Oct 7, 2013, at 10:25 AM, Dave d...@looktowindward.com wrote:

 Hi,
 
 I don't think that will work for me in this case as I need the images to be 
 scrolled smoothly without gaps and AFAIK, using a table view cell will cause 
 a gap - you can add a fragment of an image.
 
 Thanks anyway
 All the Best
 Dave
 
 On 7 Oct 2013, at 18:11, Steve Christensen puns...@mac.com wrote:
 
 Have you thought about representing your images as cells in a UITableView? 
 If so, you could use something like BBTableView 
 (https://github.com/bharath2020/UITableViewTricks). It's a subclass of 
 UITableView lays out cells along an arc but it also has support for infinite 
 scrolling, so you could just use the relevant pieces. Plus UITableView will 
 handle putting the right image in the right vertical location, based on your 
 data source.
 
 
 On Oct 7, 2013, at 9:21 AM, Dave d...@looktowindward.com wrote:
 
 Hi,
 
 I'd like to be able to Scroll Infinitely in a Scroll, e.g. when the 
 scrolling is past the last item in the Scroll start displaying the first 
 and when scrolling before the first item, starting displaying the last. The 
 items in this case are UIImageViews and they have a fixed height and a 
 variable width and no one image will be wider that the Scroll View itself. 
 Also it needs to work with pagingEnables = NO, e.g. there will be more than 
 one Image visible.
 
 I've playing around a bit and found a some sample code that sort of does it 
 but it doesn't handle the wrapping the Images smoothly (is was written to 
 have paging enabled). 
 
 My plan was/is to detect when the scrolling had hit before the first/after 
 the last and to move the first Subview to the End or the Last one to the 
 beginning, depending on the direction of movement, but at the moment, I 
 can't seem to see a way of detecting these conditions.
 
 I logged contentOffset and contentSize in the scrollViewDidScroll delegate 
 method and got these results:
 
 
 scrollViewDidScroll Offset: {4017, 0}   - Size: {5119, 200}
 scrollViewDidScroll Offset: {4061, 0}   - Size: {5119, 200}
 scrollViewDidScroll Offset: {4095, 0}   - Size: {5119, 200}
 
 When hitting the end and
 
 scrollViewDidScroll Top Scroll View Offset: {106, 0}  - Size: {5119, 200}
 scrollViewDidScroll Top Scroll View Offset: {24, 0}   - Size: {5119, 200}
 scrollViewDidScroll Top Scroll View Offset: {-0, 0}   - Size: {5119, 200}
 
 When hitting the start.
 
 I'm not sure how if I can detect the start/end conditions using these 
 values?
 
 Any points on the best way to implement this would greatly appreciated!
 
 All the Best
 Dave


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Infinite Scroll View?

2013-10-07 Thread Kyle Sluder
On Mon, Oct 7, 2013, at 11:04 AM, Steve Christensen wrote:
 Does it not work to set the row height to the height of each of the
 images and then use a custom UITableViewCell that contains a UIImageView
 that fills the cell? The other benefit is that you don't have to have
 more images in memory than are visible within the table view's frame.
 (This may not be an issue if there aren't that many, of course.)

Dave is scrolling horizontally, not vertically. UITableView is of no
help here.

--Kyle Sluder
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Infinite Scroll View?

2013-10-07 Thread Kyle Sluder
On Mon, Oct 7, 2013, at 09:21 AM, Dave wrote:
 Hi,
 
 I'd like to be able to Scroll Infinitely in a Scroll, e.g. when the
 scrolling is past the last item in the Scroll start displaying the first
 and when scrolling before the first item, starting displaying the last.
 The items in this case are UIImageViews and they have a fixed height and
 a variable width and no one image will be wider that the Scroll View
 itself. Also it needs to work with pagingEnables = NO, e.g. there will be
 more than one Image visible.
 
 I've playing around a bit and found a some sample code that sort of does
 it but it doesn't handle the wrapping the Images smoothly (is was written
 to have paging enabled). 
 
 My plan was/is to detect when the scrolling had hit before the
 first/after the last and to move the first Subview to the End or the Last
 one to the beginning, depending on the direction of movement, but at the
 moment, I can't seem to see a way of detecting these conditions.

It seems fairly straightforward, if a little labor intensive, to figure
out the width and placement of all your image views, override
-layoutSubviews to position only the ones that are potentially visible,
and implement
-scrollViewWillEndDragging:withVelocity:targetContentOffset: to figure
out where to end scrolling, based on the current velocity.

--Kyle Sluder
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com