jin
jin

Reputation: 2155

Why UIActionSheet not support my landscape?

I have a app with tabbarcontroller, two controller with it, and now in one controller I show a uiactionsheet in portrait model:

UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"" delegate:nil cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Del" otherButtonTitles:nil,nil];

actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
[actionSheet showInView:self.view];
actionSheet.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin;
[actionSheet release];

and I found that when I change the mode to landscape, it not work, because it not response the controller delegate:

-(void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration

and if the actionsheet not show , the controller can change for landscape , why? Thank you very much!!!

Upvotes: 0

Views: 2110

Answers (1)

Ares
Ares

Reputation: 5903

Try this:

UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"Some text..."
                           delegate:self
                  cancelButtonTitle:@"Cancel"
             destructiveButtonTitle:@"Delete"
                  otherButtonTitles:@"Button 1",@"Button 2",nil];

  if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 3.0 ||
      UIDeviceOrientationIsPortrait([[UIDevice currentDevice] orientation])) {
    [sheet showInView:self.view];
  } else {
    [sheet showInView:self.view.window];
  }

Upvotes: 3

Related Questions