Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The real problem comes in, when your interface is rotated to landscape and the parent view controller has a transformation on it. Believe me, that's a realistic scenario, doh. Then the action sheet is clipped and you can't use the parentViewController because it is transformed. The solution to avoid all these issues is to create a new window, add a rotatable view controller as rootViewController and use its view to display the sheet.</p> <pre><code>CGRect applicationRect = [[UIScreen mainScreen] bounds]; UIWindow* actionSheetWindow = [[UIWindow alloc] initWithFrame:applicationRect]; RotationViewController* rootViewController = [[RotationViewController alloc] initWithNibName:nil bundle:nil]; actionSheetWindow.rootViewController = rootViewController; [rootViewController release]; actionSheetWindow.hidden = NO; UIActionSheet* actionSheet = [[UIActionSheet alloc] initWithTitle:nil]; [actionSheet setCancelButtonWithTitle:@"Cancel" handler:^{ actionSheetWindow.hidden = YES; [actionSheetWindow release]; }]; [actionSheet showInView:rootViewController.view]; </code></pre> <p>The code above uses BlocksKit, but you can do it also by using the actionSheet delegate and instance properties.</p> <p>RotationViewController is just a UIViewController subclass that implements</p> <pre><code>- (void) viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor clearColor]; self.view.opaque = NO; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload