Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
IOS7 UIAlertView未调用-(void)取消单击按钮索引:(NSInteger)按钮索引已设置动画:(BOOL)已设置动画_Ios7_Uialertview - Fatal编程技术网

IOS7 UIAlertView未调用-(void)取消单击按钮索引:(NSInteger)按钮索引已设置动画:(BOOL)已设置动画

IOS7 UIAlertView未调用-(void)取消单击按钮索引:(NSInteger)按钮索引已设置动画:(BOOL)已设置动画,ios7,uialertview,Ios7,Uialertview,我将UIAlertView子类化,并覆盖该函数 [- (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated]; 在IOS6上,当我按下Ok按钮时,它被调用; 但在IOS7上,它不起作用 为什么它不起作用? 当我按下Ok按钮时,我想检查[alertView textFieldAtIndex:0]上的输入是否正确;如果不是真的,alertView不会关闭,我会在alertView上添加一

我将UIAlertView子类化,并覆盖该函数

[- (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated];
在IOS6上,当我按下Ok按钮时,它被调用; 但在IOS7上,它不起作用

为什么它不起作用? 当我按下Ok按钮时,我想检查
[alertView textFieldAtIndex:0]
上的输入是否正确;如果不是真的,alertView不会关闭,我会在alertView上添加一个抖动动画; 我怎样才能实现这种效果

多谢各位

我重写函数,如下所示:

// Override to customise when alert is dimsissed
- (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated {

    if (_shakingDelegate && [_shakingDelegate respondsToSelector:@selector(alertView:canDismissWithClickedButtonIndex:)]) {
        BOOL canDismiss = YES;
        canDismiss = [_shakingDelegate alertView:self canDismissWithClickedButtonIndex:buttonIndex];
        if (canDismiss) {
            [super dismissWithClickedButtonIndex:buttonIndex animated:animated];
        }
    }
}

当我在IOS 7中按下按钮时,它不会被调用。

很抱歉,您不能在IOS 7中将UIALertView子类化

因为我认为IOS 7的布局已经改变了(我没有尝试过)


将您自己的视图设置为alertview。。。希望有帮助

谢谢,我必须自定义alertView以避免解决IOS7和IOS6之间的差异。