开发者

How to widen UIActionSheet to fit the text in iPad?

开发者 https://www.devze.com 2023-03-11 14:13 出处:网络
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 butto

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'开发者_StackOverflowt 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:

How to widen UIActionSheet to fit the text in iPad?

Thx in advance...


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消