Note that there are some explanatory texts on larger screens.

plurals
  1. POUIActionSheet in Landscape has incorrect buttonIndicies
    primarykey
    data
    text
    <p>I have an action sheet that is causing me grief on the iphone in Landscape orientation. Everything displays just fine, but in Landscape, the first real button has the same index as the cancel button and so the logic doesn't work.</p> <p>I've tried creating the actionSheet using initWithTitle: delegate: cancelButtonTitle: destructiveButtonTitle: otherButtonTitles: but that was just the same, my current code is as follows;</p> <pre><code>UIActionSheet* actionMenu = [[UIActionSheet alloc] init]; actionMenu.delegate = self; actionMenu.title = folderentry.Name; actionMenu.cancelButtonIndex = 0; [actionMenu addButtonWithTitle:NSLocalizedString(@"str.menu.cancel",nil)]; [self addActiveButtons:actionMenu forEntry:folderentry]; [actionMenu showInView:[self.navigationController view]]; [actionMenu release]; </code></pre> <p>The addActiveButtons method basically configures which buttons to add which it does using code like this;</p> <pre><code>[menu addButtonWithTitle:NSLocalizedString(@"str.menu.sendbyemail",nil)]; </code></pre> <p>There are perhaps 6 buttons at times so in landscape mode the actionSheet gets displayed like this;</p> <p><img src="https://i.stack.imgur.com/SP7GE.png" alt="action sheet"></p> <p>My delegate responds like this;</p> <pre><code>- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { NSLog(@"Cancel Button Index is : %d",actionSheet.cancelButtonIndex); NSLog(@"Button clicked was for index : %d",buttonIndex); NSString *command = [actionSheet buttonTitleAtIndex:buttonIndex]; DLog(@"COMMAND IS: %@ for index: %d",command,buttonIndex); if ([command isEqualToString:NSLocalizedString(@"str.menu.sendbyemail",nil)]) { // Do stuff here } if ( ... similar blocks ... ) { } } </code></pre> <p>In the example shown, I am finding that cancelButtonIndex is 0 as expected, but so is the button index for the first other button! This means if <strong>I click on the second (Save to Photos) button</strong> for example, my debug output looks like this;</p> <p><em>Cancel Button Index is : 0</em></p> <p><em>Button clicked was for index : 1</em></p> <p><em>COMMAND IS: Send by Email for index: 1</em></p> <p>I've tried various permutations and am now tearing my hair out wondering what I'm missing. I've had a good search around but the other problems people seem to be having are display issues, rather than functionality ones.</p> <p><strong>Can anyone see where I've gone wrong?</strong></p> <p>PS. I know this isn't the greatest UI experience, but I figure that most users will actually be in portrait most of the time or using the iPad version of the app so I'm prepared to accept the actionsheet default behaviour for landscape assuming I can get it to actually work!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload