Permalink
Browse files

* Fix issue with reordering items

  • Loading branch information...
1 parent 19245cd commit b6cfbe57951d501bde57a91097ee0384b410a80e @mattball committed Apr 29, 2009
Showing with 11 additions and 0 deletions.
  1. +11 −0 MBCoverFlowView.m
View
@@ -413,6 +413,11 @@ - (void)setContent:(NSArray *)newContents
[oldContent release];
+ // Update the layer indices
+ for (CALayer *layer in [_scrollLayer sublayers]) {
+ [layer setValue:[NSNumber numberWithInteger:[self.content indexOfObject:[layer valueForKey:@"representedObject"]]] forKey:@"index"];
+ }
+
[_scroller setNumberOfIncrements:fmax([self.content count]-1, 0)];
self.selectedIndex = self.selectedIndex;
}
@@ -836,6 +841,12 @@ - (void)_recachePlaceholder
- (void)_setSelectionIndex:(NSInteger)index
{
+ if (index < 0) {
+ index = 0;
+ } else if (index >= [self.content count]) {
+ index = [self.content count] - 1;
+ }
+
if ([self infoForBinding:@"selectionIndex"]) {
id container = [[self infoForBinding:@"selectionIndex"] objectForKey:NSObservedObjectKey];
NSString *keyPath = [[self infoForBinding:@"selectionIndex"] objectForKey:NSObservedKeyPathKey];

0 comments on commit b6cfbe5

Please sign in to comment.