PDA

View Full Version : bar button action triggers when I touch the flexible space in toolbar




fenrus110
Oct 29, 2008, 01:50 PM
I have a screen in landscape orientation with a UIToolbar at the bottom with 5 UIBarButtonItem's with flexible space between them. I wrote my IBAction and hooked them up. So it looks like this on the bottom:
X-X-X-X-X

They all work fine, but I can also trigger the action when I touch the flexible space to the left of the button. Is this a bug or something?

In Interface Bulder, the flexible space is of type UIBarButtonItem. In the connections page, there is nothing in the Sent Actions.



SqueegyX
Oct 29, 2008, 02:26 PM
I think the toolbar is just thinking that you missed and is activating the nearest button.

lawicko
Oct 30, 2008, 08:41 AM
I had similar problem some time ago, but in my case the action called was the default action connected with the view actually presented just above my toolbar (above in sense of y axis). I think the problem was that the toolbar actually forwarded the touches to the first responder, and it is possible that the main view was underneath (in sense of z axis) my toolbar, that's why default action was called. Instead of using standard UIToolbar try to subclass it and implement all UIResponder methods in your subclass. Leave the methods empty and see what happens. Or at least swith userInteractionEnabled off for your toolbar and see if it helps, don't know if buttons will work in this set up though.