iPhone SDK Cocoa Touch-将触摸从父UIView传递到子UIScrollview [英] iPhone sdk Cocoa Touch - Pass touches down from parent UIView to child UIScrollview

查看:44
本文介绍了iPhone SDK Cocoa Touch-将触摸从父UIView传递到子UIScrollview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在IB的xib中有一个UIView,里面是一个UIScrollview,它是一个80x80的小正方形,并动态加载8个左右的80 x 80缩略图.

I have a UIView inside my xib in IB and inside that is a UIScrollview that is a small 80x80 square and dynamically loaded with 8 or so 80 x 80 thumbnail images.

UIScrollview不会裁剪图像,以便它们向两侧延伸,因此您可以左右滑动以将所选图像滚动到中心,分页处于打开状态,以便它们捕捉每个图像.

The UIScrollview is not clipping the images so that they extend out either side so you can swipe left and right to scroll a chosen image into the the centre, paging is on so they snap ti each image.

我进行了研究,发现这是执行此操作的最佳方法,并且可能是唯一的方法.

I have researched and found this is the best and possibly only way to do this.

出于某种原因,UIScrollview位于容器" UIView中,在那里可以接收触摸/滑动并将其传递给UIScrollview的子级,否则所有触摸都必须在80x80的小UIScrollview区域中开始,而我希望它们位于图像行中的任何位置.

The UIScrollview sits in a 'container' UIView for one reason, it is there to receive the touches/swipes and pass them down to it's child the UIScrollview as otherwise all touches would have to start in the small 80x80 UIScrollview area and I wan them to be anywhere along the row of images.

我已经在某处看到一些示例代码,但是无法实现.

I have seen some sample code somewhere for doing this but just can not implement it.

从头到尾将我视为菜鸟,应该如何在IB中设置UIView和UIScrollview以允许传递任何触摸,并且应该在哪里放置什么代码?

Treat me as a noob, starting from beginning to end, how should the UIView and UIScrollview be set up in IB to allow any touches to be passed, and what code should I put into where?

UIView设置为scroll_container,子UIScrollview设置为char_scroll

The UIView is set up as scroll_container and the child UIScrollview is char_scroll

目前,除了将触摸从父母传递给孩子之外,其他所有操作都正常,并且现在,当我想要成为触摸时,必须始终在UIScrollview(中间的80x80小框)内开始触摸能够在长480X80的水平父UIView中向左或向右滑动,并且仍然可以滚动子UIScrollview.

At the moment I have got it all working except for the touches being passed from the parent to the child, and at the moment the touches have to always start inside the UIScrollview (tiny 80x80 box in centre) when I want to be able to swipe left or right in the long 480X80 horizontal parent UIView and have this still scroll the child UIScrollview.

希望您能帮助您理解我的意思!

Hope you can help and understand what I mean!

推荐答案

大多数情况下都是这样做的.我尝试子类化UIView来传递触摸事件,但是我的第一次尝试没有用,而是找到了这个,而是:

The way you're doing it is mostly there. I've tried subclassing UIView to pass touch events down, but my first attempt didn't work and I found this, instead: How to extend UIScrollView's response area

基本上,可以将UIScrollView子类化以扩展其hitTest范围.您仍然拥有包含的UIView,但是它将是被动的.

Basically, subclass UIScrollView to extend its hitTest range. You'll still have the containing UIView, but it will be passive.

这篇关于iPhone SDK Cocoa Touch-将触摸从父UIView传递到子UIScrollview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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