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: [email protected] [mailto:[email protected]] 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 protected]) 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: http://lists.apple.com/mailman/options/cocoa-dev/jim.adams%40sas.com This email sent to [email protected] _______________________________________________ Cocoa-dev mailing list ([email protected]) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
