Odd question about UIViews in UIScrollView
Odd question about UIViews in UIScrollView
- Subject: Odd question about UIViews in UIScrollView
- From: "Eric E. Dolecki" <email@hidden>
- Date: Fri, 27 Aug 2010 09:23:43 -0400
I have a UIScrollView that I am placing custom UIViews into. Album covers
with metadata. Right now just for testing, when I create the UIView to add
to the scroll view, I am also setting an int variable in the UIView...
AlbumCover *lad = [[AlbumCover alloc] initWithFrame:CGRectMake(190, 5, 200,
200)];
[lad setAlbumCover:@"lad.jpg" firstLine:@"The Number of the Beast"
secondLine:@"Live After Death" thirdLine:@"Iron Maiden" isCurrent:NO
index:1];
covers = [[AlbumCoverDisplay alloc] initWithFrame:CGRectMake(0, 50, 320,
300)];
[self.view addSubview:covers];
[covers addAlbum:test];
Inside each album cover UIView I have declared an int in the .h called
myIndex. When the setAlbumCover method is called, I set myIndex = index. I
am logging the int value (which I've declared in my .h interface as it's set
by the method. These values are correct as I see them NSLogged.
The trouble is inside each AlbumCover view, I have a touchesBegan method
where I determine single or double touches. On a single I do:
NSLog(@"%d",myIndex);
Sometimes its correct, and sometimes it's off by one (if it was supposed to
be 0 it will log 1). So sometimes it's off by one (+). If I flip through
views in the scroll view (pagination enabled), a view that was reporting
correctly wlll report incorrectly when it comes back into view.
This is not going to be my final implementation (I plan on doing this in a
much better fashion), but wondering why. If I set tags the same way, they
too seem to get off by 1 (I trace [self tag] from within the album cover
itself and it can get screwed up too).
Is this a noob error on my part (I assume that it is)?
Google Voice: (508) 656-0622
Twitter: eric_dolecki XBoxLive: edolecki PSN: eric_dolecki
http://blog.ericd.net
_______________________________________________
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