RE: Truncating UIActionSheet labels
RE: Truncating UIActionSheet labels
- Subject: RE: Truncating UIActionSheet labels
- From: Jim Adams <email@hidden>
- Date: Wed, 28 Jul 2010 15:36:49 +0000
- Thread-topic: Truncating UIActionSheet labels
There is no way I would use a UIActionSheet for this type of menu. You lose way to much control over the information display. I think I would look for a different paradigm like a UITableView in a popover window.
-----Original Message-----
From: cocoa-dev-bounces+jim.adams=email@hidden [mailto:cocoa-dev-bounces+jim.adams=email@hidden] On Behalf Of Fritz Anderson
Sent: Wednesday, July 28, 2010 11:13 AM
To: Steve Christensen
Cc: Cocoa-Dev List
Subject: Re: Truncating UIActionSheet labels
On 27 Jul 2010, at 6:16 PM, Steve Christensen wrote:
> Although you say that the button labels are generated dynamically, does it really not make sense for you to generate the alert title and/or message strings dynamically and use static button labels (OK/Cancel, Yes/No, etc.)? Both of those fields are set up to resize to fit the strings. Otherwise it seems like you're fighting against the design of UIActionSheet.
I think you may be conflating UIAlertView (the window-like thing that has a message in the upper half and buttons across the bottom) and UIActionSheet (in iPad, appears in a popover and contains a stack of buttons).
I should have observed list hygiene and posted my code. Here is what I mean:
===========
NSArray * textbooks = [Textbook allTextbooks]; // Assume 8 textbooks.
NSArray * names = [textbooks valueForKey: @"name"];
CGRect buttonRect = self.textbookButton.frame;
UIActionSheet * sheet = [[UIActionSheet alloc]
initWithTitle: @"Textbooks"
delegate: self
cancelButtonTitle: nil
destructiveButtonTitle: nil
otherButtonTitles: nil];
for (NSString * name in names)
[sheet addButtonWithTitle: name];
[sheet showFromRect: buttonRect
inView: self.view
animated: YES];
===========
A name like "Adventures in French Cookery, volume 3" will be displayed as "Adventures in Fren...", which gives you three apparently-identical options. I'm hoping for "Advent...lume 3".
Grooming the data set is possible, but unpleasant, unless you count doing the middle truncation by hand in the for loop as grooming. And then you return to my problem of having truncations that are only an approximate fit.
UNLESS you use the -[NSString sizeWithFont...] extensions iteratively, which means guessing at font and width, and I'm skeptical whether those will work without a graphics context. UIButton and UILabel know all this stuff already, and can do it correctly just by setting a property.
- F
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden