我们如何知道iPhone中的表格视图中的滚动到顶部(按下顶部)(How we know the Scroll to top ( push to top) in table view in iPhone

编程入门 行业动态 更新时间:2024-10-22 20:35:19
我们如何知道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 }

更多推荐

本文发布于:2023-08-05 21:01:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1437841.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:按下   视图   表格   iPhone   Scroll

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!