UIAlertView 未禁用所有交互

发布于 2024-11-17 18:09:25 字数 228 浏览 0 评论 0原文

当显示 UIAlertView 时是否可以与其他窗口进行交互。

我想到的解决方案是在 UIAlertView 窗口上添加一个额外的 UIWindow 或尺寸较小的警报。

有人有任何建议/解决方案如何实现这一目标吗?

谢谢

编辑:
我必须使用 UIAlertView 实例。我已经找到了一种方法来识别显示 UIAlertView 的时刻。

Is it possible to use interaction with other windows when a UIAlertView is showing.

Solutions i thought about is an extra UIWindow falling over the UIAlertView window or an alert with a smaller size.

Has anybody any suggestions/solutions how to achieve this?

Thanks

EDIT:
I have to use a UIAlertView instance. I already found a way to recognize the moment when an UIAlertView is shown.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夏天碎花小短裙 2024-11-24 18:09:25

只是一个想法,使用警报文本和按钮创建自定义视图并将其显示为 UIAlertView。单击按钮隐藏该视图。这将解决你的目的。您可以使用以下代码进行相同的操作。请根据您的要求调整 x/y/高度/宽度。

UIView *customAlert = [[UIView alloc] initWithFrame:CGRectMake(100,100,100,100)];
UILabel *lblText = [[UILabel alloc] initWithFrame:CGRectMake(0,0,100,30)];
lblText.text =@"Your alert text";

[customAlert addSubView:lblText];

UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self action:@selector(hideAlertView:) forControlEvents:UIControlEventTouchDown];
[button setTitle:@"OK" forState:UIControlStateNormal];
button.frame = CGRectMake(30.0, 50.0, 50.0, 50.0);
[customAlert addSubview:button];

[self.view addSubView:customAlert];

-(IBAction)hideAlertView:(id)sender
{
     [customAlert removeFromSuperView];
}

编辑

由于 UIAlertView 具有 MODAL 行为,您无法触摸应用程序的任何其他部分,直到它被关闭为止。

Just a thought create custom view with your alert text and button and show it as UIAlertView. Clicking on button hide that view. Which will solve your purpose. Below Code you can use for the same. Plz adjust x/y/height/width as per your requirement.

UIView *customAlert = [[UIView alloc] initWithFrame:CGRectMake(100,100,100,100)];
UILabel *lblText = [[UILabel alloc] initWithFrame:CGRectMake(0,0,100,30)];
lblText.text =@"Your alert text";

[customAlert addSubView:lblText];

UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self action:@selector(hideAlertView:) forControlEvents:UIControlEventTouchDown];
[button setTitle:@"OK" forState:UIControlStateNormal];
button.frame = CGRectMake(30.0, 50.0, 50.0, 50.0);
[customAlert addSubview:button];

[self.view addSubView:customAlert];

-(IBAction)hideAlertView:(id)sender
{
     [customAlert removeFromSuperView];
}

EDIT

As UIAlertView is of MODAL behavior you can not touch any other part of your application until it is dismissed.

乱了心跳 2024-11-24 18:09:25

快速解决方案:

  // Define a view
  var popup:UIView!
  func showAlert() {
    // customise your view
    popup = UIView(frame: CGRect(x: 100, y: 200, width: 200, height: 200))
    popup.backgroundColor = UIColor.redColor()

    // show on screen
    self.view.addSubview(popup)

  }

  func dismissView(){
    // Dismiss the view from here
    popup.removeFromSuperview()
  }

Swift Solution:

  // Define a view
  var popup:UIView!
  func showAlert() {
    // customise your view
    popup = UIView(frame: CGRect(x: 100, y: 200, width: 200, height: 200))
    popup.backgroundColor = UIColor.redColor()

    // show on screen
    self.view.addSubview(popup)

  }

  func dismissView(){
    // Dismiss the view from here
    popup.removeFromSuperview()
  }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文