2014-07-09 4 views
0

scrollPosition = UITableViewScrollPositionTop을 사용하여 맨 위에 선택된 행을 표시하는 프로그램이 있습니다. 그러나 아래로 스크롤하여 다른 행을 클릭하면 스크롤러는 처음 선택한 행으로 스크롤합니다. 스크롤하는 동안 나는 UIScrollPositionTop을 비활성화 할 수있는 방법이 있습니다. 아니면 다른 해결책을주십시오?스크롤 할 때 scrollPosition을 사용하지 않습니다.

이 메서드는 일정한 간격을두고 호출되어 행을 강조 표시 (선택)합니다.

-(void)highlightcell:(int *)rows { 

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:*rows inSection:0]; 
[tableview selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionTop]; 

} 

답변

0
당신은 스크롤이 시작될 때 감지 할 수있는 UIScrollView 대리자를 사용하고이 정지 할 때, 다음 아래로 스크롤 상태를 유지하는 플래그를 사용할 수

: 당신의 방법 그리고

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView 
{ 
    isScrolling = YES; 
} 

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate { 
    isScrolling = NO; 
} 

:

-(void)highlightcell:(int *)rows { 
    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:*rows inSection:0]; 

if (isScrolling) { 
    [tableview selectRowAtIndexPath:indexPath animated:YES  scrollPosition:UITableViewScrollPositionNone]; 
} 
else { 
    [tableview selectRowAtIndexPath:indexPath animated:YES  scrollPosition:UITableViewScrollPositionTop]; 
} 

} 
+0

답해 주셔서 감사합니다. 하지만 여전히 작동하지 않습니다. 내가 아래로 스크롤하여 아무 행이나 클릭하려고 할 때마다 현재 강조 표시된 행으로 다시 스크롤됩니다. –

+1

이제 효과가있었습니다. scrollViewDidEndDownEndDragging과 scrollViewDidEndAccerlating 메서드를 사용하고 권장대로 BOOL 값을 사용했습니다. 많은 감사 인사 –

0

이 작업을 수행하려고 ..

Self.Table_small.scrollEnabled=NO;