2010-11-20 17 views
2

- (BOOL) tableView: (UITableView *) tableView canMoveRowAtIndexPath: (NSIndexPath *) indexPath { NSUInteger satır = [indexPath satır]; (satır == 0) NO döndürür; return YES; }UITableView: düzenleme modunda yaklaşık satır hareket

Sorunum: satır 0 için NO belirtsem de satır 1'i değiştirmek için sıra 1'i sürüklemeye çalışırsam, animasyon bunun yine de olmasını sağlar. Sorun, yukarıdaki yöntemin, sadece satırın sağında bir hareket simgesi olup olmadığına karar vermesidir. Sıra 0'ın nasıl değiştirileceği ile ilgili herhangi bir fikir hiç değişmedi mi?

cevap

4

UITableViewDelegate kullan

- (NSIndexPath *)tableView:(UITableView *)tableView targetIndexPathForMoveFromRowAtIndexPath:(NSIndexPath *)sourceIndexPath toProposedIndexPath:(NSIndexPath *)proposedDestinationIndexPath 

.

Böyle bir şey yapabilirsiniz:

if ([proposedDestinationIndexPath row] > 0) { 
    return proposedDestinationIndexPath; 
} 

NSIndexPath *betterIndexPath = [NSIndexPath indexPathForRow:1 inSection:0]; 
return betterIndexPath; 

+0

sayesinde fabian (Joe Conway & Aaron Hillegass tarafından "iPhone Programlama" Kimden)! aradığım kesin yöntem. – bogardon