【问题标题】:Disable all interaction UIViewcontroler when push new UIVIew推送新 UIVIew 时禁用所有交互 UIViewcontroler
【发布时间】:2013-07-19 06:28:05
【问题描述】:

我在这里使用此代码UIView Popup like UIAlertView 创建 UIVIew 相同的 UIalertView。 我从 UIViewController 推送新的 UIViewAlert,但我希望 UIViewAlert 出现,UIViewController 不点击或选择,然后 UIViewAlert 消失,UIVIewController 点击正常。在我的 ViewController 中有 1 个 tablview,1 个 tabbar 包括 4 个 UIButton。

我将新的 UIViewAlert 称为:

    DetailView *detailAlert = [[DetailView alloc] init];
    [self.view addSubview:detailAlert];
    [detailAlert show];
    [detailAlert release];

有人给我看吗?谢谢

【问题讨论】:

    标签: iphone ios objective-c uiview uiviewcontroller


    【解决方案1】:

    您可以通过在启动警报视图之前添加BLOCK SCREEN 来实现此目的,请参阅下面的代码

    self.blockView=[[UIView alloc] initWithFrame:self.view.frame];
    self.blockView.backgroundColor = [UIColor blackColor];
    self.blockView.alpha = .5;
    self.blockView.userInteractionEnabled=NO;
    [self.view addSubview:self.blockView];
    
    DetailView *detailAlert = [[DetailView alloc] init];
    [self.view addSubview:detailAlert];
    [detailAlert show];
    [detailAlert release];
    

    然后,当您删除警报视图时,请执行以下操作

    [self.blockView removeFromSuperview];
    

    【讨论】:

    • 谢谢,它尝试了你的代码,但它是一个视图,无法禁用视图控制器的交互
    • [self.view bringSubviewToFront:self.blockView];添加到self.view后尝试添加..
    【解决方案2】:

    您可以使用弹出窗口显示您的 DetailView。

    将此用于演示。 https://github.com/martinjuhasz/MJPopupViewController

    【讨论】:

    • 谢谢,但如果你点击背景它会消失。如果我想点击按钮,它会关闭???
    • 请在 UIViewController+MJPopupViewController.m 文件中注释这一行 //[dismissButton addTarget:self action:@selector(dismissPopupViewControllerWithanimation:) forControlEvents:UIControlEventTouchUpInside];
    • 它可以用于 UIVIew 而不是 UIVIewController 吗?
    • 你可以使用 UIViewController 代替 UIView
    【解决方案3】:

    您可以创建一个颜色清晰的视图控制器并以模态方式呈现它,请参见下面的 Swift 2 示例:

    private func TransparentViewController() -> UIViewController {
      let transparentViewController = UIViewController(nibName: nil, bundle: nil)
      transparentViewController.modalPresentationStyle = .OverCurrentContext
      transparentViewController.modalTransitionStyle = .CrossDissolve
      transparentViewController.view.backgroundColor = UIColor.clearColor()
      return transparentViewController
    }
    

    现在您可以在显示 HUD 之前从视图控制器中显示它:

    let transparentViewController = TransparentViewController()
    self.presentViewController(transparentViewController, animated:false, completion: nil) 
    

    【讨论】:

      猜你喜欢
      • 2010-11-18
      • 1970-01-01
      • 1970-01-01
      • 2012-06-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-12
      • 1970-01-01
      相关资源
      最近更新 更多