gpt4 book ai didi

objective-c - IKImageBrowserView 移动项目没有动画

转载 作者:行者123 更新时间:2023-12-03 17:26:03 34 4
gpt4 key购买 nike

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

comparison is always true due to limited range of data type

最佳答案

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

关于objective-c - IKImageBrowserView 移动项目没有动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4680738/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com