ios - UIAlert 对话框的动画非常奇怪?

标签 ios objective-c uikit

我遇到了一件奇怪的事情。我有我的 View ,然后我有一个 ScrollView ,我用一个按钮在其中设置动画。一切正常,但 native 对话框开始出现奇怪的动画? (参见 GIF 示例)当我注释掉我的代码并运行时 - 这不再发生。下面是问题代码。知道我需要更改什么以使其不影响 iOS UIAlerts 吗?任何帮助将不胜感激!

enter image description here

- (IBAction)openMenu:(id)sender {


    if (draw1 == 0) {

        draw1 = 1;

        [openMenu setTitle:@"Close" forState:UIControlStateNormal];

        [UIScrollView beginAnimations:nil context:nil];
        [UIScrollView setAnimationDuration:0.5];
        [UIScrollView setAnimationDelay:0.0];
        [UIScrollView setAnimationCurve:UIViewAnimationCurveEaseOut];

        [UIButton beginAnimations:nil context:nil];
        [UIButton setAnimationDuration:0.5];
        [UIButton setAnimationDelay:0.0];
        [UIButton setAnimationCurve:UIViewAnimationCurveEaseOut];

        scrollView.frame = CGRectMake(0, 0, 768, 100);
        openMenu.frame = CGRectMake(690, 195, 60, 60);

        [self.view bringSubviewToFront:scrollView];

        [UIScrollView commitAnimations];

    } else {


        draw1 = 0;

        [openMenu setTitle:@"Open" forState:UIControlStateNormal];
        [UIScrollView beginAnimations:nil context:nil];
        [UIScrollView setAnimationDuration:0.5];
        [UIScrollView setAnimationDelay:0.0];
        [UIScrollView setAnimationCurve:UIViewAnimationCurveEaseOut];

        [UIButton beginAnimations:nil context:nil];
        [UIButton setAnimationDuration:0.5];
        [UIButton setAnimationDelay:0.0];
        [UIButton setAnimationCurve:UIViewAnimationCurveEaseOut];

        scrollView.frame = CGRectMake(0, -100, 768, 100);
        openMenu.frame = CGRectMake(690, 95, 60, 60);

        [UIScrollView commitAnimations];

    }
}

最佳答案

系统对话框试图显示在其父 View 的中心,但您正在更改父 View 的边界。在允许 UIActionSheet 出现之前,请确保您的 View 已完成动画。

关于ios - UIAlert 对话框的动画非常奇怪?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18404339/

相关文章:

ios - 如何在 ios 中生成包含图像数组的单页 pdf 文件?

ios - 为什么没有创建数据库?

ios - 钥匙串(keychain)找不到项目但无法创建项目

iphone - 如何在 iPhone 上创建时间线

swift - CellForRow 被延迟调用

ios - Cocos2d 和 UIKit 动画不同步

iphone - UIImage 到 BitmapContext

ios - 在 iOS 13 中设置 UISearchField 的占位符文本颜色

objective-c - 如何将我的程序添加到 OS X 系统菜单栏?

ios - 对 ios7 的 shm_open 调用现在导致在 O_CREAT (EPERM) 期间不允许操作