Zigglzworth
Zigglzworth

Reputation: 6803

iPhone / iOS - UIButton not recieving touches when it is lower on view

I have a really strange problem. I have a UIView and on that view I have 3 UIButtons.

the UIView has a frame

CGRectMake(0, 0, 320, 300)

and I put the buttons on the frame one next to the other with height 50 pixels on the bottom part of the UIView but still within it.

For some reason the UIButtons don't receive the touch but if I raise their height they do... what could be the cause of this strange problem?

Upvotes: 1

Views: 1007

Answers (3)

Jonathan Plackett
Jonathan Plackett

Reputation: 2426

Try changing CGRectMake(0, 0, 320, 300) to CGRectMake(0, 100, 320, 300) or similar to move the view down the page and compare the behaviour with moving the buttons inside the view.

Does this have the same effect as moving the buttons?

This should help you work out if the problem is within this view, or outside of it.

Upvotes: 0

Daniel
Daniel

Reputation: 23359

You may also look into the frame size of the UIButton's parent view. when I started out I often overlooked this and actually what happened is the button is not completely inside the parent. But due to the fact the parent view is not clipping that view I could see it... but not interact with part or all of it.

Upvotes: 0

touti
touti

Reputation: 1164

maybe there is a component at the same place with the button with a different zindex try this mothode to bring your btn to front

[yourView bringSubviewToFront:yourButton]

Upvotes: 2

Related Questions