简体   繁体   English

如何在UITableView中滚动时隐藏/显示图像?

[英]How can i hide/show images while scrolling in UITableView?

I'm new to iOS programming and i want to learn something about UITableView. 我是iOS编程的新手,我想学习一些关于UITableView的东西。

I have some images in UITableViewCell. 我在UITableViewCell中有一些图像。 I want to hide my images when scrolling start then i want to show them when scrolling stop. 我想在滚动开始时隐藏我的图像然后我想在滚动停止时显示它们。

How can i do that ? 我怎样才能做到这一点 ? Is there a method or something else about that ? 有没有方法或其他相关的东西?

UITableView inherits from UIScrollView, thus you can in your tableView delegate receive UIScrollViewDelegate callbacks. UITableView继承自UIScrollView,因此您可以在tableView委托中接收UIScrollViewDelegate回调。

Implement the delegate method 实现委托方法

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView

which tells the delegate when the scroll view is about to start scrolling the content. 当滚动视图即将开始滚动内容时告诉委托。

and

- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset

which tells the delegate when the user finishes scrolling the content. 当用户完成滚动内容时告诉委托。

Read the ScrollViewDelegate Reference . 阅读ScrollViewDelegate参考

你只需要实现scrollview委托方法就可以知道滚动何时停止,然后设置一个bool值并重新加载表,并根据bool值你可以显示和隐藏图像。当滚动开始时将bool设置为NO 。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM