Re: UIActionSheet -addButtonWithTitle weirdness on iPad
Re: UIActionSheet -addButtonWithTitle weirdness on iPad
- Subject: Re: UIActionSheet -addButtonWithTitle weirdness on iPad
- From: David Duncan <email@hidden>
- Date: Thu, 03 Oct 2013 13:22:43 -0700
On Oct 3, 2013, at 12:58 PM, Fritz Anderson <email@hidden> wrote:
>
> On 3 Oct 2013, at 12:59 PM, David Duncan <email@hidden> wrote:
>
>> On Oct 2, 2013, at 11:49 PM, Markus Spoettl <email@hidden> wrote:
>>
>>> On 10/2/13 10:40 PM, David Duncan wrote:
>>>> On Oct 2, 2013, at 9:33 AM, Markus Spoettl <email@hidden> wrote:
>>>>
>>>>> On the iPad (both device and simulator) this produces a sheet with
>>>>> "Button2" missing. No matter how many buttons one adds, the last one added
>>>>> goes missing.
>>>>>
>>>>> On iPhone (again both device and simulator) this produces a sheet with the
>>>>> expected buttons "Cancel", "Button1", "Button2".
>>>>>
>>>>> If I set the cancelButtonTitle: parameter to nil, both iPad and iPhone
>>>>> behave correctly, iow "Button1", "Button2".
>>>>
>>>>
>>>> Try setting the cancelButtonIndex after you’ve added the extra buttons. The
>>>> safest way to do this would be to stash off the number of buttons after
>>>> you’ve created it (via numberOfButtons) then add your extra buttons, then
>>>> reset the cancelButtonIndex based on the stashed value. -- David Duncan
>>>
>>> Thanks Duncan, I will try that. However, as Fritz pointed out, the HIG says cancel buttons are undesireable, so I guess the easiest solution is to do that.
>>
>>
>> When displaying an action sheet as a popover, the action sheet will automatically remove the cancel button, so you shouldn’t need to do that yourself (in fact I would recommend against it).
>>
>> Thinking a bit about this you may want to use canceledItemIndex instead of numberOfButtons, but either way its something to try.
>> --
>> David Duncan
>
> The point of this thread is that it _doesn't_ remove the Cancel button. It removes the _last_ button, Cancel or not. And UIActionSheet knows which button is Cancel, because it was set in the initializer.
No, I understand. I’m just wondering if the issue is that the action sheet has incorrectly altered its notion of the cancel button, or if it really is just incorrectly removing the last button. If the former, then updating its notion of which button is the cancel button should be a sufficient work around.
> And (I'm sorry I haven't tried it yet) if the action popover arises from another popover, the Cancel button isn't supposed to be removed at all.
Which is also why it seems better to not leave out the cancel button, if possible, because then you have to detect this case instead of letting the framework do it.
> In my experiment with an action sheet anchored to a bar button, .numberOfButtons was as expected — if you specify Cancel plus to other buttons, the count is three — but only two buttons are visible. The button array contains all three buttons, as expected.
I would expect that, but I would wonder if cancelButtonIndex is 0 or 2 in that case. Which value it is would indicate where the ultimate bug is and what the better work around is.
--
David Duncan
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden