iOS手势,触摸事件的传递问题
高洛峰
高洛峰 2017-04-17 17:48:44
0
1
288

我是希望封装一个控件,它是可以上下滑动的.
可以设置一定的偏移高度,是对顶部高度100的内容自动进行隐藏和显示,假如设置100.
向上滑动时优先隐藏100高度上的内容,向下滑动时优先显示这100高度
就算子内容里面有scrollView,那么滑动scrollView时,无论向上还是向下,都优先满足该控件的顶部操作,然后再scrollView内部内容滑动。

目前我用了ScrollView作为控件的基本使用
可是对于这几个方法的处理尝试了一下,也无法达到我想要的效果

// @property(nonatomic) BOOL delaysContentTouches;   
// @property(nonatomic) BOOL canCancelContentTouches;
// - (BOOL)touchesShouldBegin:(NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event inContentView:(UIView *)view;
// - (BOOL)touchesShouldCancelInContentView:(UIView *)view;

比如我的控件内部主要分为2部分,上部分类似于广告,下部分是子界面,子界面高度就跟控件一样高,而且我的控件是不能滑出去的,能滑动的距离也就100高度而已。如果内部有scrollView或者listView的下拉刷新,用户在拉的时候,若广告已经出来了,就能下拉刷新了,若广告没有出来,用户一下是先慢慢出现广告,继续拉的时候才内部的scrollView的下拉才出来

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(1)
Peter_Zhu

If I understand correctly, your needs should be similar to the common hidden navigation bar, such as the navigation bar and author information on the Jianshu app when reading an article. It is hidden when you scroll up and scrolls down. Just come out.

This is on a separate layer. If you want to "display these 100 heights first when sliding down", it means that it is not on the same layer as the sliding content. It's one layer above the sliding content.

Generally, it is processed in the didScroll callback event to determine the scrolling direction, or KVC monitors the contentOffset of scrollView.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!