Thursday, July 14, 2011

Adding Text Message to an ActionSheet

The ActionSheet supports one line of text, the title, which as the name implies, is displayed across the top of the Alert. See the image below for an example.




There is an undocumented method that you can call to add another line of text just below the title. The setMessage method accepts an NSString and will display the text in a font slightly larger than the title.
What follows is a short example to create an ActionSheet with an additional message displayed.

UIActionSheet *options = [[UIActionSheet alloc] 
          initWithTitle:@"HomeBrewing Styles" 
          delegate:self
          cancelButtonTitle:@"I Can't Decide"
          destructiveButtonTitle:nil
          otherButtonTitles:@"English", @"American", @"Imperial", nil];
[options setMessage:@"Select a Style of IPA:"];
[options showInView:self.view];
 
 
The output of the code above is shown in the figure that follows.

No comments:

Post a Comment