bar button action triggers when I touch the flexible space in toolbar

Discussion in 'iOS Programming' started by fenrus110, Oct 29, 2008.

  1. macrumors regular

    Joined:
    Mar 24, 2008
    #1
    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.
     
  2. macrumors regular

    Joined:
    Mar 24, 2008
    #2
    I think the toolbar is just thinking that you missed and is activating the nearest button.
     
  3. macrumors member

    Joined:
    Jul 17, 2008
    #3
    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.
     

Share This Page