简体   繁体   English

停止UIAlertView解雇

[英]Stop UIAlertView from dismissing

Can you stop UIAlertView from dismissing? 你可以阻止UIAlertView解雇吗?

I want based on what button is pressed, to either animate adding a UITextField, or dismiss it. 我希望根据按下的按钮,动画添加UITextField或关闭它。 But I can't add a text field after the alert is dismissed. 但是在取消警报后我无法添加文本字段。

You should implement the UIAlertViewDelegate method : 您应该实现UIAlertViewDelegate方法:

- (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex

and based on the button index you can perform your custom action. 并且基于按钮索引,您可以执行自定义操作。

Otherwise you should either create your own alertview class or subclass UIAlertView. 否则,您应该创建自己的alertview类或子类UIAlertView。

If you choose to subclass you can override the method : 如果您选择子类,则可以覆盖该方法:

-(void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated 

to avoid dismissing the alertView if a specific button is pressed 如果按下特定按钮,则避免解除alertView

如果您只是想在UIActionSheet被解除后添加UITextField ,那么添加一个方法,当ActionSheet被解除时,然后调用TextField的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM