Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

UIScrollView subview touch problem

moopfmoopf Posts: 152
edited July 2010 in iOS SDK Development
Hi,

New here, in fact new to the SDK but getting on well with it (plenty of previous coding experience to draw on). However, I've been hitting my head against a brick wall today with UIScrollView and it making subviews, e.g. UIImageViews, no longer be touchable. When I move the image views outside the scroll view it's fine, so I know they're working and the touchesBegan:withEvent is processing as it should do.

Here's what I'm doing in the initWithFrame:
scroller = [[UIScrollView alloc] initWithFrame:CGRectMake(0,0,320,400)];
scroller.scrollEnabled = YES;
CGSize sz;
sz.width = 320;
sz.height = 800;
scroller.contentSize = sz;
scroller.tag = 400;
scroller.userInteractionEnabled = YES;
scroller.delaysContentTouches = YES;
scroller.canCancelContentTouches = NO;
[self addSubview:scroller];

(I've tried all different combinations of delaysContentTouches and canCancelContentTouches just to see if they made a difference, originally I hadn't got either in there. But they don't seem to alter anything)

And then the image views:
buttonPlay = [[UIImageView alloc] initWithFrame:CGRectMake(20,320,40,40)];
buttonPlay.image = [UIImage imageNamed:@blah.jpg];
buttonPlay.userInteractionEnabled = YES;
buttonPlay.tag = 100;
[scroller addSubview:buttonPlay];
		
buttonSettings = [[UIImageView alloc] initWithFrame:CGRectMake(80,320,40,40)];
buttonSettings.image = [UIImage imageNamed:@blah.jpg];
buttonSettings.userInteractionEnabled = YES;
buttonSettings.tag = 101;
[scroller addSubview:buttonSettings];

Basically no touch events are being generated anywhere I click within the scroll view and I'm at a loss to work out why.

Not sure if it's related either but I can't get a UILabel to respond to a touch either, even though I've enabled userInteractionEnabled for it - even trying a simple project I can't get a UILabel to generate a touch event at all.

Any help on the above scroll view issue would be appreciated as it's driving me nuts!

Cheers
Post edited by moopf on
Now developing an interactive children's story for the iPad - <a href="http://www.arthurandcharles.com/"; target="_blank">Arthur and Charles</a>

Replies

  • moopfmoopf Posts: 152
    edited June 2008
    Been playing around with this again this morning and still no joy. Any help would be greatly appreciated as I simply cannot seem to get any interaction with the contents of the scroll view to register (apart from actually scrolling the scroll view itself!)
    Now developing an interactive children's story for the iPad - <a href="http://www.arthurandcharles.com/"; target="_blank">Arthur and Charles</a>
  • akashtakyarakashtakyar Posts: 1
    edited November 2008
    I am going through the similar problem here. Please share if you or anyone else was able to solve the touch issue with the scroll view. thanks....eagrly waiting for the reply.
  • tusharbhattatusharbhatta Posts: 6
    edited April 2009
    I am going through the similar problem here. Please share if you or anyone else was able to solve the touch issue with the scroll view. thanks....eagrly waiting for the reply.

    Hi All,

    Is there any solution ? Anyone please help ?
  • 934texas934texas Posts: 19
    edited April 2009
    Hi All,

    Is there any solution ? Anyone please help ?

    I'm looking for one right now... find anything?
  • tawpietawpie Posts: 348
    edited April 2009
    moopf...

    what sort of a view controller are you using (in otherwords, where is scroller being added as a subview)? I put imageViews into a scrollView and can touch though just fine, my scrollView is managed by my mainViewController and that's where I intercept all touches.
    "Hardware <u>will</u> break. Software comes broken" Unknown<br />
    <a href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=294438793&mt=8"; target="_blank">Calc-12E</a> <-- ditch your old calculator.<br />
    <a href="htt
  • 934texas934texas Posts: 19
    edited April 2009
    Thanks for the offer, I ended up just adding a button to the UIScrollView subclass because I was pressed for time. Later on need to figure out why I couldn't get touches to work on the other subviews...
  • KennyChongKennyChong Posts: 411 @ @
    edited June 2010
    934texas wrote: »
    Thanks for the offer, I ended up just adding a button to the UIScrollView subclass because I was pressed for time. Later on need to figure out why I couldn't get touches to work on the other subviews...



    Hi All,

    I am encountering the same problem now. Any experience that you can share with me pleaesssssse? I have been bouncing on walls last couple of days on this one.

    Thanks
    KennyChong<br />
    iPhone SDK Fanatic!
  • SebastatoSebastato Posts: 1
    edited July 2010
    Looks like as if the scrollview blocks any touches when the content rectangle is smaller or of same size as its bounds. Really strange behaviour.
Sign In or Register to comment.