2013-05-29 27 views
5

Im phát hiện UITableView di chuyển theo cách nàyLàm thế nào để phát hiện mà UITableView được di chuyển

'

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate: (BOOL)decelerate{ 
isDragging_msg = FALSE; 
[tblSongs reloadData]; 

}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{ 
isDecliring_msg = FALSE; 
[tblSongs reloadData]; } 


- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{ 
isDragging_msg = TRUE; 

}

- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView{ 
isDecliring_msg = TRUE; } 

'

nhưng tôi phải tải sevaral UITableViews Theo phát hiện này, tôi phải tải lại từng bảng một cách riêng biệt. Vậy làm cách nào tôi có thể phát hiện bảng nào hiện đang cuộn.

Cảm ơn

Trả lời

8

Bảng xem là một cái nhìn cuộn như đã đề cập ở đây: Is it possible to access a UITableView's ScrollView In Code From A Nib?

Vì vậy, bạn chỉ có thể kiểm tra xem cuộn trôi qua trong từng phương pháp đại biểu cho dù xem di chuyển là quan điểm bảng bạn muốn, ví dụ:

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{ 
    if (scrollView == tblSongs) { 
     isDragging_msg = FALSE; 
     [tblSongs reloadData]; 
    } 
} 
0

Bạn nghĩ gì về tham số scrollView trong tất cả các phương pháp này?

+0

Tôi có thể thêm một số thẻ chỉ cho chế độ xem cuộn của bảng không? – iDia

+0

hoặc chế độ xem cuộn có cùng số thẻ của UITableView – iDia

0

Bạn có thể phát hiện sự kiện trên mỗi bảng. UITableView event

Tiếp nhận các sự kiện liên lạc về việc sử dụng UITableView:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
    //<your stuff> 

    [super touchesBegan:touches withEvent:event]; 
} 

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
    //<your stuff> 

    [super touchesMoved:touches withEvent:event]; 
} 

- (void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event 
{ 
    //<your stuff> 

    [super touchesEnded:touches withEvent:event]; 
} 

- (void)touchesCancelled:(NSSet*)touches withEvent:(UIEvent*)event 
{ 
    //<your stuff> 
    [super touchesCancelled:touches withEvent:event]; 
} 

và có thể tải lại bất kỳ tableview cụ thể. Cảm ơn

Các vấn đề liên quan