我在我的应用中使用 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
。
最好创建 UIView 的自定义 View 子类,即绘制 使用
- (void)drawRect:(CGRect)rect
方法以编程方式查看。再创建一个容器类(继承自
NSObject
) 用于创建和绑定(bind)您的标题/密码和确定按钮 将您的自定义委托(delegate)属性添加到您的自定义警报中 view.这样我们就可以像这样实现我们的自定义委托(delegate)方法clickedButtonAtIndex
方法。据我所知,iOS7 中的 block /动画没有变化。
关于iphone - 阻止在 IOS 7 中不被调用和不动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19267162/