Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4341190
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:27:04+00:00 2026-05-21T11:27:04+00:00

I have an action sheet that is causing me grief on the iphone in

  • 0

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.

I’ve tried creating the actionSheet using initWithTitle: delegate: cancelButtonTitle: destructiveButtonTitle: otherButtonTitles: but that was just the same, my current code is as follows;

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];

The addActiveButtons method basically configures which buttons to add which it does using code like this;

[menu addButtonWithTitle:NSLocalizedString(@"str.menu.sendbyemail",nil)];

There are perhaps 6 buttons at times so in landscape mode the actionSheet gets displayed like this;

action sheet

My delegate responds like this;

- (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 ... ) { }

}

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 I click on the second (Save to Photos) button for example, my debug output looks like this;

Cancel Button Index is : 0

Button clicked was for index : 1

COMMAND IS: Send by Email for index: 1

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.

Can anyone see where I’ve gone wrong?

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T11:27:05+00:00Added an answer on May 21, 2026 at 11:27 am

    OK, fixed it by counting how many buttons I was adding and then adding the cancel button as the last option, so my code looks like this;

    int added = [self addActiveButtons:actionMenu forEntry:folderentry];
    
    [actionMenu addButtonWithTitle:NSLocalizedString(@"str.menu.cancel",nil)];
    actionMenu.cancelButtonIndex = added;
    

    Hope that helps someone else struggling witht the same issue!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an iPhone app that uses an action sheet but I can't work
I have an Action Sheet that is called from my root view controller using
I have an iOS iPhone app for which I need the Action Sheet-style buttons
I have read on another post ( how to dismiss action sheet ) that
I have an action sheet with options that vary depending on the circumstances. There
I have an action handling a form post, but I want to make sure
I have an action called List that shows the results of a search. It
i have form action file in another directory but some file send to this
I have an action method that depending on some conditions needs to return a
I have two action methods that are conflicting. Basically, I want to be able

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.