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/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to