aslı
aslı

Reputation: 8914

How to widen UIActionSheet to fit the text in iPad?

I'm using UIActionSheet in a landscape mode application in iPad. Some of my button's texts don't fit the width and they're cropped from the end. In iPhone this is handled and my action sheet buttons fit into the frame even if they are long. I didn't understand why this is different in iPad. Do you guys have any ideas about how I can accomplish something as adjustsFontSizeToFitWidth method does to UILabels?

Here's how I create and display my action sheet:

UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];

for (NSString *bank in self.getBanksResponse.banks) {
    [actionSheet addButtonWithTitle:bank];
}

[actionSheet showFromRect:self.bankButton.frame inView:self.view animated:YES];
[actionSheet release];

Here's the screenshot of my action sheet:

enter image description here

Thx in advance...

Upvotes: 3

Views: 764

Answers (1)

Luke
Luke

Reputation: 11476

Your code seems fine - I have two ideas for you:

1) In the showFromRect method called from your actionsheet, edit the passed in rect to be wider and see how it goes.

2) If the above did not work, then you might want to look into subclassing it to accommodate your text... or look at UIPopoverController which could hold your data in a table view.

Upvotes: 2

Related Questions