2010-11-16 94 views
0

我正在开发一个iPhone应用程序,我想在其中使用自定义警报表。定制是必需的,因为我想设置图像警报张按钮,更改这些按钮等UIALertView自定义

我做了以下事情的大小:

  1. 创建的UIView用,我想自定义控件。
  2. 创建并显示UIAlertView中
  3. 在UIAlertView中(UIAlertViewDelegate)的委托方法即

    - (void)willPresentAlertView:(UIAlertView *)alertView 
    

    我删除UIAlertView中的所有子视图,并加入我的自定义视图作为子视图。

一切工作正常,直到这里。由于我使用了自定义按钮,我需要通过在UIAlertView上调用dismissWithClickedButtonIndex:animated:来显式地在按钮的Action方法中删除警报表。 即使UIALertView被解雇,大约需要0.5秒才能被解雇。 有人可以帮我解决这个延迟的问题,解散或警报视图按钮的其他定制方式。

感谢和问候, 迪帕

+1

需要知道您使用的代码来解雇它。 – 2010-11-16 13:25:46

+0

[alertView dismissWithClickedButtonIndex:0 animated:NO] – spd 2010-11-16 13:35:00

回答

0

我可以通过将YES传递给dismissWithClickedButtonIndex:animated来调用:例如调用[alertView dismissWithClickedButtonIndex: 0 animated: YES]。最初,我是通过国旗为NO。但是,我不知道如果我们将动画标志设置为YES,则需要更少的时间。 有人知道吗?

0

而不是做这个

/* 
1. Created UIView with customized controls that I wanted. 
2. Created and displayed UIAlertView 
3. In the delegate method of UIAlertView (UIAlertViewDelegate) 
*/ 

的做到这一点:

像这样创建一个类:

@interface CustomAlertView : UIAlertView 
{ 
    //For ex: 

    UIButton *myCustomButton; 
//and other custom controls 
} 

它下面的方法实现:

-(id)init 
{ 

} 

在上述方法中使用:

[self addSubView: myCustomButton]; 

我已经给了刚刚的想法。我有代码,但不是现在与你分享。 如果您无法执行上述操作,我将在稍后提供。

谢谢。

+0

谢谢Ganesh。我按照你的说法尝试过。但是,如何在执行自定义按钮操作时避免调用dismissWithClickedButtonIndex:animated:on alert-view。在alert-view上显式调用dismiss仍然需要时间。你在执行过程中如何避免这种情况? – spd 2010-11-17 04:04:09

+0

我可以通过将YES传递给dismissWithClickedButtonIndex:animated:call,例如[alertView dismissWithClickedButtonIndex:0 animated:YES]。最初,我是通过国旗为NO。但是,我不知道如果我们将动画标志设置为YES,则需要更少的时间。 有人知道吗? – spd 2010-11-17 06:13:05

相关问题