This is the code I am writing to display UIActionSheet
.
actionSheet = [[UIActionSheet alloc] initWithTitle:NSLocalizedString(@"updateresponseforrecurring", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) destructiveButtonTitle:nil otherButtonTitles:
NSLocalizedString(@"updateresponseonlyforthis", nil),
NSLocalizedString(@"updateresponseforallactivities", nil),
nil];
actionSheet.tag = 2;
[actionSheet showInView:[UIApplication sharedApplication].keyWindow];
This is what I get using this :
Clearly, second option is longer and thus the size gets smaller to accommodate the width.
But I want the same font size for all the options which leaves me with multiline. Also tried with UIAlertController
but not able to set multiline text.
How to achieve this ?
As of iOS 8, app devs should use UIAlertController rather than this class. Extensions may not use this class at all. The UIActionSheet control is a convenient way to allow the application user to choose among alternative actions. The following code and diagram are taken from the "Action Sheets" section of the "iOS Standard Controls" sample.
UIAlertController replaces both UIAlertView and UIActionSheet, thereby unifying the concept of alerts across the system, whether presented modally or in a popover. Unlike the classes it replaces, UIAlertController is a subclass of UIViewController.
A UIAlertController object displays an alert message to the user. This class replaces the UIActionSheet and UIAlertView classes for displaying alerts. After configuring the alert controller with the actions and style you want, present it using the presentViewController:animated:completion: method.
Did you know that UIAlertView and UIActionSheet (as well as their respective delegate protocols) are deprecated in iOS 8? It’s true. ⌘-click on UIAlertView or UIActionSheet in your code, and check out the top-level comment: UIAlertView is deprecated.
This seems to work in iOS 10 and Swift 3.1:
UILabel.appearance(whenContainedInInstancesOf: [UIAlertController.self]).numberOfLines = 2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With