iOS 7: UIAlertView created in UIActionSheet delega

2019-05-26 23:14发布

The issue only can be reproduced in iOS 7.

In the delegate function:- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex, if a UIAlertView is created, the alert view cannot auto rotate. Here is the sample code:

- (IBAction)buttonTapped:(id)sender
{
    UIActionSheet *actionSheet = [[UIActionSheet alloc]
                                  initWithTitle:@"action sheet"
                                  delegate:self
                                  cancelButtonTitle:@"cancel"
                                  destructiveButtonTitle:@"ok"
                                  otherButtonTitles:nil];
    [actionSheet showInView:self.view];
}

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    UIAlertView *alert = [[UIAlertView alloc]
                          initWithTitle:@"alert"
                          message:nil
                          delegate:self
                          cancelButtonTitle:@"ok"
                          otherButtonTitles:nil];
    [alert show];
}

Is this a bug of iOS 7? If yes, is there any way to make the alert view auto rotate with the other view in the screen?

1条回答
仙女界的扛把子
2楼-- · 2019-05-26 23:43

Try presenting the alertview from another delegate method of UIActionSheet. This does work:

- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex

This surely looks like a bug in iOS7 :)

查看更多
登录 后发表回答