Bug 14680 - UIActionSheet has multiple buttons with the same index
Summary: UIActionSheet has multiple buttons with the same index
Status: RESOLVED NORESPONSE
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 6.9.8.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-09-12 09:28 UTC by info
Modified: 2016-05-24 20:06 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
I've attached a little movie to demonstrate the issue. (4.57 MB, video/mp4)
2013-09-12 09:28 UTC, info
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED NORESPONSE

Description info 2013-09-12 09:28:32 UTC
Created attachment 4853 [details]
I've attached a little movie to demonstrate the issue.

For some reason my UIActionSheet has 2 buttons with index 6 on 3.5" devices (when the UIActionSheet becomes too large on 3.5" devices, the layout changes). So just to make this clear, it's working perfectly on iPhone 5 & iPad.

Now obviously my question here is how I can fix this.
Theoretically it's impossible that 2 different buttons have the same index.

Here is a little relevant code how I build the actionsheet:

// Create other options actionsheet
_actionSheetOtherOptions = new UIActionSheet(_languageManager.GetTranslationForKey("DOCUMENTS_MANAGE", LanguageManager.TYPE_INTERFACE));

// Available other options (save to)
foreach(String identifier in ConfigurationData.AVAILABLE_REPO_TYPES)
    _actionSheetOtherOptions.AddButton (_languageManager.GetTranslationForKey ("SAVE_TO_" + identifier, LanguageManager.TYPE_INTERFACE));

// Other available options
_otherOptionsEmailBtnIndex = _actionSheetOtherOptions.AddButton(_languageManager.GetTranslationForKey("DOCUMENT_EMAIL", LanguageManager.TYPE_INTERFACE));

// Delete button
_otherOptionsDeleteBtnIndex = _actionSheetOtherOptions.AddButton(_languageManager.GetTranslationForKey("DOCUMENT_DELETE", LanguageManager.TYPE_INTERFACE));

// Set the delete button to as destructive button
_actionSheetOtherOptions.DestructiveButtonIndex = _otherOptionsDeleteBtnIndex;

// Cancel button for iPhone
if (iSigner.iOS.Service.UtilityService.iPhone) {
    _otherOptionsCancelBtnIndex = _actionSheetOtherOptions.AddButton (_languageManager.GetTranslationForKey ("CANCEL", LanguageManager.TYPE_INTERFACE));

    // Set cancel button as cancel button
    _actionSheetOtherOptions.CancelButtonIndex = _otherOptionsCancelBtnIndex;
}

// Button in the actionsheet was clicked, handle it
_actionSheetOtherOptions.Dismissed += actionSheetOtherOptionsDismissedHandler;
Comment 2 Sebastien Pouliot 2013-09-12 10:11:59 UTC
Can you try two things:

1. don't set DestructiveButtonIndex and CancelButtonIndex properties since you are not using the default ctor (but indirectly the long one).

<quote>If you use that method to create a destructive button, you should not change the value of this property.</quote> [1]

2. Initialize your instance with

_actionSheetOtherOptions = new UIActionSheet();
_actionSheetOtherOptions.Title = _languageManager.GetTranslationForKey("DOCUMENTS_MANAGE",
LanguageManager.TYPE_INTERFACE);

for the same reason as above (avoid the long init/ctor where Apple ask you not to set *Index properties).

[1] https://developer.apple.com/library/ios/documentation/uikit/reference/UIActionSheet_Class/Reference/Reference.html#//apple_ref/occ/instp/UIActionSheet/destructiveButtonIndex

If that does not work please attach a small, self-contained, test case so we can try this.
Comment 3 info 2013-09-12 10:23:42 UTC
Well, if I don't set the DestructiveButtonIndex they all have separate indexes indeed.
The problem however, iOS changes the DestructiveButton its place and its index doesn't update (it should be 0 when its placed on top). I don't see how I can fix this?
Comment 4 Sebastien Pouliot 2013-09-12 10:28:35 UTC
Did you try #2 ? i.e. use the default actor *and* keep your *Index properties changes
Comment 5 info 2013-09-12 10:39:28 UTC
I did: http://pastie.org/8320030. I still have 2 buttons with index 6 (destructive button "should" be 0).

What do you mean with keep your *Index properties changes?
Comment 6 Sebastien Pouliot 2013-09-12 11:03:39 UTC
> What do you mean with keep your *Index properties changes?

In #1 I asked you to " don't set DestructiveButtonIndex and CancelButtonIndex properties". In #2 I wanted you to set them, but use another ctor (so Apple warning about the properties would not apply)
Comment 7 info 2013-09-12 11:14:07 UTC
If I don't set the DestructiveButtonIndex everything is fine. Regardless what constructor I use.
Now I'm creating the actionsheet with an empty constructor like this: new UIActionSheet(). When I don't set the DestructiveButtonIndex all buttons have different indexes, when I do set the DestructiveButtonIndex there are 2 buttons with index 6..
Comment 8 Sebastien Pouliot 2016-05-24 20:06:11 UTC
We have not received the requested information. If you are still experiencing this issue please provide all the requested information and re-open the bug report. Thanks!