在UIAlertView上显示UIActionSheet [英] Showing UIActionSheet over UIAlertView

查看:55
本文介绍了在UIAlertView上显示UIActionSheet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于特定的服务器通知,我应该显示一个UIActionSheet.但是这里的问题是该事件到来的同时,如果任何UIAlertView已经显示在任何视图控制器上,则会使UIActionSheet禁用(在为警报视图按ok之后,我无法在视图控制器上选择任何内容,因为该视图被禁用,因为UIActionSheet).任何人都面临此类问题,有什么解决方案的想法吗?

For a specific server notification I am supposed to show an UIActionSheet. But problem here is when that event comes, at the same time if any UIAlertView already showing on any view controller, it make the UIActionSheet disabled( After pressed ok for alert view I am not able to select anything on view controller , view got disabled because of UIActionSheet). Anyone faced this kind of problem, Any idea how to solve it?

我已经尝试过在显示操作表之前关闭警报视图,但是由于我在许多控制器中都有许多警报视图,因此我需要关闭哪个警报视图.所有都在该控制器本地.如何解决这个问题.

I have tried by dismissing alert view before showing action sheet, however which alert view do I need to dismiss as I have many alert view in many controller. All are local to that controllers. How to solve this problem.

注意:iPod不会出现相同的问题,因为它不允许在响应UIActionSheet之前单击确定".

Note: Same problem won't come for iPod, as it wont allow to click ok before responding to UIActionSheet.

推荐答案

获取一个名为AlertAlertView的全局警报视图.现在,当您显示警报视图时,请检查该警报视图,然后显示并分配.像

Take a Global Alert view named it as activeAlertView. Now when you show a alert view please check that alert view and then show and assign. Like

在.h中声明一个属性并对其进行合成

declare a property in .h and synthesize it

@property (nonatomic, retain) UIAlertView *activeAlertView;

然后在尝试显示警报时使用以下代码.

then use the below code when try to show an alert.

if(self.activeAlertView){
    [self.activeAlertView dismissWithClickedButtonIndex:0 animated:YES];
}
UIAlertView *localAlert = [[UIAlertView alloc] initWithTitle:@"Title" message:@"Your message" delegate:nil cancelButtonTitle:@"cancel" otherButtonTitles:nil, nil ];
[localAlert show];
self.activeAlertView = localAlert;
[localAlert release];

这样,您的activeAlertview将保留当前aler视图的引用,并在显示actionSheet之前关闭警报视图.

this way your activeAlertview will keep the current aler view's reference and before show the actionSheet dismiss the alert view.

这篇关于在UIAlertView上显示UIActionSheet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆