IKImageBrowserView 移动项目没有动画

发布于 2024-10-12 00:18:02 字数 1716 浏览 8 评论 0原文

我有一个 IKImageBrowser 设置,看起来运行良好。我已将其设置为允许重新排序,并将动画设置为“是”(在我的 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;

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寂寞花火° 2024-10-19 00:18:02

正如 NSGod 上面提到的,将 int index 更改为 NSUInteger index 解决了问题

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文