Re: Strange problem with UIButton in bar button item
Re: Strange problem with UIButton in bar button item
- Subject: Re: Strange problem with UIButton in bar button item
- From: Laurent Daudelin <email@hidden>
- Date: Wed, 19 Sep 2012 12:55:28 -0700
I'm actually using a custom subclass of UIButton named UIGlossyButton. It's open-source somewhere. The reason being that I have to be able to set the text color, among other things. I guess I could have used the setTitleTextAttributes:forState: inherited from UIBarItem but was just a bit too lazy.
BTW, for those that are interested by the "bug", I found a workaround. Put a UIView in your left bar button item so it stays there. Make a connection from your controller to the left bar button item. Create a button and configure it like you want. Make a connection from your controller to your button.
At runtime, in viewDidLoad:, set the custom view of your bar button item:
self.navigationItem.leftBarButtonItem.customView = self.button3;
The button then appears at full width and is completely tappable as you would expect. Not sure if I want to waste time to report this as a bug but it sure looks like one.
-Laurent.
--
Laurent Daudelin
AIM/iChat/Skype:LaurentDaudelin http://www.nemesys-soft.com/
Logiciels Nemesys Software email@hidden
On Sep 19, 2012, at 12:18, Alex Zavatone <email@hidden> wrote:
> Same symptom I had.
>
> But you're using a UIButton, a round rect button. Is there any reason you're not using a Bar Button Item? Do you have a Nav controller before this?
>
> Can you drag a Bar Button Item into the top bar?
>
> It certainly will look more consistent to the IOS look and feel.
>
> <PastedGraphic-3.png>
>
> On Sep 19, 2012, at 2:47 PM, Laurent Daudelin wrote:
>
>> I think I know why. Here is a snapshot in the simulator:
>> <iOS Simulator Screen shot Sep 19, 2012 11.43.55.png>
>>
>> Notice the left button. Initially, and up to now, it looks exactly as "Button 2" in IB in Xcode. They are both UIButtons that were dragged from the objects palette. I didn't do anything to them, except to wire them to a method in the view controller. The weird thing is that if I tap outside Button 1, it still registers the tap even though it's outside the button.
>>
>> So, something is resizing the button in the left bar button item but when I look in Xcode, I don't see anything.
>>
>> -Laurent.
>> --
>> Laurent Daudelin
>> AIM/iChat/Skype:LaurentDaudelin http://www.nemesys-soft.com/
>> Logiciels Nemesys Software email@hidden
>>
>> On Sep 19, 2012, at 11:02, Alex Zavatone <email@hidden> wrote:
>>
>>> Before you do all that, just try deleting the button and replacing it.
>>>
>>> It would be interesting in any case if the problem persists or not.
>>>
>>> On Sep 19, 2012, at 1:29 PM, Laurent Daudelin wrote:
>>>
>>>> It's happening on 4.5 but I think that's the first time I'm using storyboards. I'll try to see if I can create a new project from scratch and reproduce the problem.
>>>>
>>>> -Laurent.
>>>> --
>>>> Laurent Daudelin
>>>> AIM/iChat/Skype:LaurentDaudelin http://www.nemesys-soft.com/
>>>> Logiciels Nemesys Software email@hidden
>>>>
>>>> On Sep 19, 2012, at 08:29, Alex Zavatone <email@hidden> wrote:
>>>>
>>>>> AHA. Same here.
>>>>>
>>>>> Which version of Xcode? Mine happened in 4.2. You've got 15 years on me, but I've never seen this period, 'til trying to create a popover using the storyboard. (There need to be better examples for this, BTW).
>>>>>
>>>>> I know man. Did you also run in to the case where the button didn't fit to your text properly?
>>>>>
>>>>> I closed and reopened the storyboard, it appeared better, then finally deleted and replaced the UIBarButtonItem.
>>>>>
>>>>> I have no idea how the mask, or hit detection area, could be offset from the button, or why this could even happen.
>>>>>
>>>>> Since you added it in a storyboard, if you have the time and desire to figure out why, try duping your storyboard, deleting everything that is not relevant and then open the storyboard up in a pList or XML editor. Maybe you'll see some coordinates that don't match up.
>>>>>
>>>>> Still, it's little things like this that keep cropping up that just end up eating so much time.
>>>>>
>>>>>
>>>>> On Sep 19, 2012, at 11:07 AM, Laurent Daudelin wrote:
>>>>>
>>>>>> Hey Alex. It was added to my iPad storyboard. I've been working for almost 20 years with Interface Builder. I've never seen anything like this and it doesn't seem to matter how many times I reconstruct the button, it still won't detect taps.
>>>>>>
>>>>>> -Laurent.
>>>>>> --
>>>>>> Laurent Daudelin
>>>>>> AIM/iChat/Skype:LaurentDaudelin http://www.nemesys-soft.com/
>>>>>> Logiciels Nemesys Software email@hidden
>>>>>>
>>>>>> On Sep 19, 2012, at 06:42, Alex Zavatone <email@hidden> wrote:
>>>>>>
>>>>>>> I've seen this last week in fact to when adding a Nav bar button item and only on the iPad.
>>>>>>>
>>>>>>> Did you add it in a storyboard, or in code?
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Sep 19, 2012, at 3:36 AM, Laurent Daudelin wrote:
>>>>>>>
>>>>>>>> I'm finding another weird problem. This is only happening on the iPad, not the iPhone. I placed a UIView inside the left and right bar button items. Inside both views are a UIImageView and a UIButton. They are almost identical. I just went for the 100th time checked all attributes of each button.
>>>>>>>>
>>>>>>>> My problem is that when I tap the left UIButton, it will not detect the touch inside unless I tap on its far left side. Tapping in the middle or on the right side of the button doesn't trigger the tap. I just can't understand. I have a similar setup in my iPhone storyboard and the left button in the left bar button item will detect the tap no matter where I tap the button.
>>>>>>>>
>>>>>>>> Has anybody ever seen something like this? I completely removed the left bar button item and added a new one, with a view inside that contains the UIImageView and the UIButton. All reconfigured. Same result.
>>>>>>>>
>>>>>>>> Anybody has any idea? Is the left bar button item on the iPad something special?
>>>>>>>>
>>>>>>>> -Laurent.
>>>>>>
>>>>>
>>>>
>>>
>>
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden