• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Truncating UIActionSheet labels
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Truncating UIActionSheet labels


  • Subject: Re: Truncating UIActionSheet labels
  • From: Fritz Anderson <email@hidden>
  • Date: Wed, 28 Jul 2010 10:13:23 -0500

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

  • Follow-Ups:
    • RE: Truncating UIActionSheet labels
      • From: Jim Adams <email@hidden>
References: 
 >Truncating UIActionSheet labels (From: Fritz Anderson <email@hidden>)
 >Re: Truncating UIActionSheet labels (From: Steve Christensen <email@hidden>)

  • Prev by Date: Sample code for "simple" sharing using Bonjour?
  • Next by Date: presentMoviePlayerViewControllerAnimated without view controller?
  • Previous by thread: Re: Truncating UIActionSheet labels
  • Next by thread: RE: Truncating UIActionSheet labels
  • Index(es):
    • Date
    • Thread