2012-12-18 3 views

답변

1

예!

(A주의로) 당신은 위임 방법 willMoveToIndexPath를 교체하고 몇 가지 수정해야 :

- (void)collectionView:(UICollectionView *)theCollectionView layout:(UICollectionViewLayout *)theLayout itemAtIndexPath:(NSIndexPath *)theFromIndexPath willMoveToIndexPath:(NSIndexPath *)theToIndexPath 
{ 

/* code removed from example code 
id theFromItem = [self.deck objectAtIndex:theFromIndexPath.item]; 
[self.deck removeObjectAtIndex:theFromIndexPath.item]; 
[self.deck insertObject:theFromItem atIndex:theToIndexPath.item]; 
*/ 

NSLog(@"From: %d %d To: %d %d", theFromIndexPath.section, theFromIndexPath.row, theToIndexPath.section, theToIndexPath.row); 

    NSMutableArray *fromSectionArray = mySectionArray[theFromIndexPath.section]; 
NSMutableArray *toSectionArray = mySectionArray[theToIndexPath.section]; 
id theFromItem = fromSectionArray.myItemArray[theFromIndexPath.item]; 
[fromSectionArray.myItemsArray removeObjectAtIndex:theFromIndexPath.item]; 
[toSectionArray.myItemsArray insertObject:theFromItem atIndex:theToIndexPath.item]; 

}

난 그냥 여기에 코드를 쓰고 있어요를 (이것은 오류가있을 수 있습니다)하지만, 나는 네가하고있는 일의 요지를 얻은 것 같아. 나는 섹션에 대해 하나의 레이어를 추가하는 것 뿐이며 "보낸 사람"및 "대상"항목은 같은 섹션에서 온 것으로 가정하지 않습니다.

주의 사항 : 이 코드는 작동하지만 섹션에 처음으로 항목이없는 경우 문제가 발생합니다.

희망이 도움이됩니다.

관련 문제