我有一個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