我有一个IKImageBrowser设置似乎运行良好。我已经设置它允许重新排序,并将动画设置为YES(在我awakeFromNib中),但是无论何时我选择并尝试重新排列图像,我都会产生奇怪的行为:IKImageBrowserView移动项目不动画
1)它们大部分时间不重新排序 2)如果他们这样做,他们不动画 3)有时图像相互之间,如果我滚动回来,他们回到他们开始的地方。
如果我想强调的图像,并删除它,它以动画和消失,预期...
这是核心动画的问题吗?我是否需要向界面构建器中的对象添加核心动画层?我跟着苹果本教程以获得这些结果: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;
比较总是如此,由于到 数据类型的限制范围
虽然它可能不涉及您所遇到的问题,你可以通过改变`INT index`为`NSUInteger index`删除该编译器警告。 – NSGod 2011-01-13 18:53:20