Tag: uialertviewdelegate

UIAlertview委托方法不在子视图控制器中调用

我有两个控制器 VC A – > Parent和VC B – > Child 警报视图委托方法即 func alertView(View: UIAlertView!, clickedButtonAtIndex buttonIndex: Int){} 在VC A声明。 当我显示来自VC B警报委托方法不会被警告button点击调用。

另一个视图控制器上的UIAlertView崩溃问题

我有2个视图控制器, ViewController 1(VC1)和2(VC2)。 在VC2中,我有一个后退和完成button。 在点击返回button时,它直接进入VC1,在完成后进行一次api调用,当它得到一个响应时,它显示一个警报视图,点击OK返回到VC1。 现在,当我进行api调用时,出现一个加载条,并在获取响应并显示AlertView时消失。 但是,如果在加载消失的第二秒的时间内,如果我点击返回并且视图改变为VC1, AlertView将popup,则VC1上将出现警报,并导致崩溃。 这是一个罕见的情况,因为没有用户会故意尝试,但我想知道是否可以在不禁用后退button的情况下pipe理崩溃。 我认为可能有其他实例这样的情况下,如果我们正在进行asynchronous调用,并且如果允许用户在等待响应时使用UI,并且如果任何错误警报假设显示在一个ViewController显示在另一个可能会导致因为警报所指的代表是前一个视图控制器的崩溃。 那么有没有办法有效地处理这种崩溃? //Alert View sample UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[[message objectAtIndex:1] capitalizedString] message:[message objectAtIndex:0] delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil] ; [alert setTag:701]; [alert show]; – (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { if ([alertView tag] == 701) if (buttonIndex == 0) { [self.navigationController popViewControllerAnimated:YES]; } }

iOS 7:在UIActionSheet委托函数中创build的UIAlertView不能自动旋转

这个问题只能在iOS 7中重现。 在委托函数中: – (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex ,如果创build了UIAlertView,则警报视图不能自动旋转。 这里是示例代码: – (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]; } 这是iOS 7的错误吗? 如果是的话,有什么办法让警报视图自动旋转与屏幕上的其他视图?

你可以在Swift中创build匿名内部类吗?

我厌倦了将整个类声明为能够通过扩展UIAlertViewDelegate来处理UIAlertView点击。 当我有多个可能的UIAlertView时,它开始感到混乱和错误,并且必须区分处理程序中被点击的内容。 我真正想要的是创build一个实现UIAlertViewDelegate协议的对象,并在显示时将这个一次性对象赋予我的UIAlertView 。 我想要这样的东西: let confirmDelegate = UIAlertViewDelegate() { func alertView(alertView: UIAlertView!, clickedButtonAtIndex buttonIndex: Int) { // Handle the click for my alertView } } 然后在显示警报时使用它: let alertView = UIAlertView(title: "Confirm", message: "Are you sure?", delegate: confirmDelegate, cancelButtonTitle: "No", otherButtonTitles: "Yes") alertView.show() 这可能没有声明一个新的类? 我知道我可以做这样的事情: class ConfirmDelegate: UIAlertViewDelegate { func alertView(alertView: UIAlertView!, clickedButtonAtIndex buttonIndex: Int) […]

clickedButtonAtIndex方法不被调用

当用户点击UIAlertView上的button时, clickedButtonAtIndex方法应该被调用,但是,它不会: 在.h我已经调用了UIAlertView协议: @interface RechercherViewController : UIViewController<UIAlertViewDelegate> { //code } 并在.m文件中我有这样的: -(void)requestFailed:(ASIHTTPRequest *)request { //quand il y aura un échec lors de l'envoie de la requête UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"TopStation" message :@"Your internet connexion is down" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; [alert release]; } – (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ if (buttonIndex == 0) { NSLog(@"buttonIndex 0"); } […]