iOS 7: UIAlertView created in UIActionSheet delegate function cannot auto rotate

陌路散爱 提交于 2019-12-22 18:10:56

问题


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:


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 :)



来源:https://stackoverflow.com/questions/19491060/ios-7-uialertview-created-in-uiactionsheet-delegate-function-cannot-auto-rotate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!