开发者

IKImageBrowserView Moving items doesn't animate

I have an IKImageBrowser setup which appears to be working well. I have set it up to allow reordering and also set animation to YES (in my awakeFromNib), however whenever I select and try and reorder the images I get strange behaviour:

1) They don't reorder most of the time 2) If they do they don't animate 3) Sometimes the images land on each other, if I scroll away and back they are back where they started.

If I highlight an image and delete it, it animates and disappears as expected...

Is this a problem with Core Animation? Do I need to add a core animation layer to the object in interface builder? I followed this tutorial from Apple to get these results: http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Conceptual/ImageKitProgrammingGuide/ImageBrowser/ImageBrowser.html#//apple_ref/doc/uid/TP40004907-CH5-SW1

Here's the code in question:

- (BOOL) imageBrowser:(IKImageBrowserView *) aBrowser moveItemsAtIndexes: (NSIndexSet *)indexes toIndex:(NSUInteger)destinationIndex{
    int index;
    NSMutableArray *temporaryArray;

    temporaryArray = [[[NSMutableArray alloc] init] autorelease];
    for(index=[indexes lastIndex]; index != NSNotFound;
        index = [indexes indexLessThanIndex:index])
    {
        if (index < destinationIndex)
            destinationIndex --;

        id obj = [mImages objectAtIndex:index];
        [temporaryArray 开发者_如何学运维addObject:obj];
        [mImages removeObjectAtIndex:index];
    }

    // Insert at the new destination
    int n = [temporaryArray count];
    for(index=0; index < n; index++){
        [mImages insertObject:[temporaryArray objectAtIndex:index]
                      atIndex:destinationIndex];
    }

    return YES;
}

Interestingly, this line throws a warning

for(index=[indexes lastIndex]; index != NSNotFound;

comparison is always true due to limited range of data type


As mentioned above by NSGod, changing int index to NSUInteger index solved the problem

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜