我们如何知道iPhone中的表格视图中的滚动到顶部(按下顶部)(How we know the Scroll to top ( push to top) in table view in iPhone)
我的iPhone应用程序中有一个表格视图
因为我想实施两个动作
当用户将表格滚动到顶部时。
当用户拉下表格视图时。
对于Ex:
If(UserScrollThe tableViewToTop) { perform action: 1 } If(UserScrollThe tableViewToDown) { perform action: 2 }我们怎么知道使用将表移到顶部 /底部..?
I have a table view in my iPhone app
in that i want to implement two actions
when user scrolls the table to top.
When the user pulls down the table view.
For Ex:
If(UserScrollThe tableViewToTop) { perform action: 1 } If(UserScrollThe tableViewToDown) { perform action: 2 }How can we know that the use move the table to Top / bottom..?
最满意答案
使用scrollView's delegate方法检查。
1)设置yourtableView.scrollView.delegate = self;
2)在.h文件中添加UIScrollViewDelegate
在.h中添加CGPoint previousContentOffset
(void)scrollViewDidScroll:(UIScrollView *)scrollView { if (scrollView.contentOffset.y > previousContentOffset.y) { //scrolled downward //perform action for scrolled downward } else { //scrolled upward //perform action for scrolled upward } previousContentOffset = scrollView.contentOffset }Check using scrollView's delegate method.
1) Set yourtableView.scrollView.delegate = self;
2) Add UIScrollViewDelegate in .h file
Add CGPoint previousContentOffset in .h
(void)scrollViewDidScroll:(UIScrollView *)scrollView { if (scrollView.contentOffset.y > previousContentOffset.y) { //scrolled downward //perform action for scrolled downward } else { //scrolled upward //perform action for scrolled upward } previousContentOffset = scrollView.contentOffset }更多推荐
发布评论