iphone - 阻止在 IOS 7 中不被调用和不动画

标签 iphone ios ios7 objective-c-blocks cgaffinetransform

我在我的应用中使用 ShakingAlertView

https://github.com/lukestringer90/ShakingAlertView

它在 IOS 6 中完美运行。但是在我更新到 IOS 7 后,它没有动画,并且没有调用错误处理的 block 函数。 下面给出摇晃警报 View 的初始化代码。

currentPass = [[ShakingAlertView alloc]initWithAlertTitle:@"Enter Current Password" checkForPassword:self.pass
                                                        usingHashingTechnique:HashTechniqueMD5
                                                        onCorrectPassword:^{
                                                            isCurrentPassConfirmed = YES;
                                                            [self._accountSource willScrollToTop];
                                                            self.password.text = @"";
                                                            [self.password becomeFirstResponder];

                                                        } onDismissalWithoutPassword:^{
                                                            //NSLog(@"hi");
                                                            [self showFailedPasswordAlert];

                                                        }];
    currentPass.alertViewStyle = UIAlertViewStyleSecureTextInput;
    [currentPass show];

下面是摇动效果的动画方法。它被正确调用但没有效果。

- (void)animateIncorrectPassword {
    // Clear the password field
    _passwordField.text = nil;

    // Animate the alert to show that the entered string was wrong
    // "Shakes" similar to OS X login screen
    CGAffineTransform moveRight = CGAffineTransformTranslate(CGAffineTransformIdentity, 20, 0);
    CGAffineTransform moveLeft = CGAffineTransformTranslate(CGAffineTransformIdentity, -20, 0);
    CGAffineTransform resetTransform = CGAffineTransformTranslate(CGAffineTransformIdentity, 0, 0);

    [UIView animateWithDuration:0.1 animations:^{
        // Translate left
        self.transform = moveLeft;

    } completion:^(BOOL finished) {

        [UIView animateWithDuration:0.1 animations:^{

            // Translate right
            self.transform = moveRight;

        } completion:^(BOOL finished) {

            [UIView animateWithDuration:0.1 animations:^{

                // Translate left
                self.transform = moveLeft;

            } completion:^(BOOL finished) {

                [UIView animateWithDuration:0.1 animations:^{

                    // Translate to origin
                    self.transform = resetTransform;
                }];
            }];

        }];
    }];

}

请帮帮我。

最佳答案

iOS7 不允许您自定义UIAlertview

  1. 最好创建 UIView 的自定义 View 子类,即绘制 使用 - (void)drawRect:(CGRect)rect 方法以编程方式查看。

  2. 再创建一个容器类(继承自 NSObject) 用于创建和绑定(bind)您的标题/密码和确定按钮 将您的自定义委托(delegate)属性添加到您的自定义警报中 view.这样我们就可以像这样实现我们的自定义委托(delegate)方法 clickedButtonAtIndex 方法。

  3. 据我所知,iOS7 中的 block /动画没有变化。

或引用此链接 https://github.com/wimagguc/ios-custom-alertview

关于iphone - 阻止在 IOS 7 中不被调用和不动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19267162/

相关文章:

iPhone游戏开发基础

iphone - 如何将一张图像分割成多个部分?

iphone - 将核心数据信息导出到 Excel 工作表

iOS 处理内存警告

ios - 无法在 ios 中调整横向 View

ios - 为什么这个简单的动画在 iOS 7 上不起作用?

iphone - 奇怪,包括 AFNetwork 的问题?

ios - 如何使用 Alamofire 更改全局变量?

ios - 是否可以检查 iOS 7 中是否启用了 iCloud KeyChain?

objective-c - UIActivityIndi​​catorView 未在 UIAlertView 中显示 - iOS7