1

我有一个看起来运行良好的 IKImageBrowser 设置。我已将其设置为允许重新排序并将动画设置为 YES(在我的 awakeFromNib 中),但是每当我选择并尝试重新排序图像时,我都会得到奇怪的行为:

1)他们大部分时间不会重新排序 2)如果他们这样做,他们不会动画 3)有时图像会彼此重叠,如果我滚动并返回,它们会回到他们开始的地方。

如果我突出显示图像并将其删除,它会按预期动画并消失......

这是核心动画的问题吗?我是否需要在界面生成器中为对象添加核心动画层?我按照 Apple 的本教程获得了这些结果:http: //developer.apple.com/library/mac/#documentation/GraphicsImaging/Conceptual/ImageKitProgrammingGuide/ImageBrowser/ImageBrowser.html#//apple_ref/doc/uid/TP40004907- CH5-SW1

这是有问题的代码:

- (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;
}

有趣的是,这条线引发了警告

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

由于数据类型的范围有限,比较总是正确的

4

1 回答 1

0

正如上面NSGod所说,改变int indexNSUInteger index解决问题

于 2011-01-24T14:36:18.197 回答