当用户开始在UITableView上滚动时,使用Alpha隐藏UIView吗? [英] Hide UIView using alpha when user starts scrolls on UITableView?

查看:85
本文介绍了当用户开始在UITableView上滚动时,使用Alpha隐藏UIView吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

viewController 由2个主要视图组成。容器视图和表格视图。

viewController is composed of 2 main views. A container view and a table view.

容器视图是顶部,上面带有所有标签,例如日期和分数。

The container view is the top section with all the labels such as the day and score.

我要当用户开始在表格视图的各天中滚动时,该容器视图将隐藏。

I want this container view to hide when a user starts scrolling through the days of the table view.

到目前为止,我有:


  1. 为此容器视图连接了 IBOutlet ,因此我可以在代码中引用它。

  2. 符合 UIScrollViewDelegate

  3. UITableView

  1. Hooked up an IBOutlet for this container view so I could reference it in the code.
  2. Conformed to the UIScrollViewDelegate
  3. Implimented all required methods for the UITableView

我知道 UITableView UIScrollView 。没有适当的 UIScrollView ,我很困惑如何使用 scrollViewDidScroll 方法并将容器视图alpha更改为当我在tableView中滚动时为0。

I know UITableView is a subclass of UIScrollView. Without a "proper" UIScrollView I am confused how to go about using the scrollViewDidScroll method and changing the container view alpha to 0 when I am scrolling in the tableView.

当用户停止滚动时,我还希望Alpha返回1。

I also want the alpha to return to 1 when the user stops scrolling.

谢谢。

注意,我没有使用UITableViewController

推荐答案

您应该使用用UITableViewController代替UIViewController,然后将UIView拖到UITable的标题部分。这将导致UIView在开箱即用的情况下完全不进行编码,而无法进行滚动。

You should use a UITableViewController instead of a UIViewController and then drag a UIView in the header section of the UITable. This will cause the UIView to get out of the way on scrolling right out of the box with no coding at all.

这篇关于当用户开始在UITableView上滚动时,使用Alpha隐藏UIView吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆