【问题标题】:Adding presented view controller above all views在所有视图之上添加呈现的视图控制器
【发布时间】:2019-12-10 22:13:48
【问题描述】:

我正在像这样在 Tabbar 上方添加一个正在播放的视图:

    let transition = CATransition()
    transition.type = CATransitionType.push
    transition.subtype = CATransitionSubtype.fromLeft
    miniPlayerView.view.layer.add(transition, forKey: nil)
    appDelegate.window?.rootViewController?.addChild(miniPlayerView)
    appDelegate.window?.addSubview(miniPlayerView.view)
    miniPlayerView.didMove()

miniPlayerView.didMove()我正在设置视图的框架

view.frame = CGRect(x: 0, y: heightAvailable - height, width: frameWidth, height: height)

现在,当我单击 NowPlaying 时,我会全屏显示它,其中有一个按钮,它将显示底部工作表弹出窗口,它出现在 MiniPlayerView 视图后面

我尝试了多个代码在所有视图上方添加弹出底部表,但它不起作用

代码示例:

    let modal = ModalViewController()
    let transitionDelegate = DeckTransitioningDelegate()
    modal.transitioningDelegate = transitionDelegate
    modal.modalPresentationStyle = .custom
    present(modal, animated: true, completion: nil)

另外,我尝试使用这个库:https://github.com/ergunemr/BottomPopup

但问题似乎在于这两行:

appDelegate.window?.rootViewController?.addChild(miniPlayerView)
appDelegate.window?.addSubview(miniPlayerView.view)

如何在 miniPlayerView v 中首先显示显示的 Bottomsheet 视图

【问题讨论】:

  • 使用 bringSubViewToFront 方法。
  • @AbuUlHassan 这不起作用
  • 为什么会这样? appDelegate.window?.bringSubview(toFront: popUpWindow)

标签: ios swift uinavigationcontroller uitabbarcontroller bottom-sheet


【解决方案1】:

在此处尝试我的代码,我在所有视图之上显示警报。如果真的有帮助,请使用它。

DispatchQueue.main.async(execute: {
        let window = UIWindow(frame: UIScreen.main.bounds)
        window.rootViewController = UIViewController()
        window.windowLevel = UIWindow.Level.alert+1

        let alert2 = UIAlertController(title: title, message: message, preferredStyle: .alert)
        let defaultAction2 = UIAlertAction(title: "OK", style: .default, handler: { action in
        })
        alert2.addAction(defaultAction2)

        window.makeKeyAndVisible()

        window.rootViewController?.present(alert2, animated: true, completion: nil)
    })

【讨论】:

  • 我不想显示警报我想要一个自定义底页
  • 是的,尝试用您的视图名称替换
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-11-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-05-18
相关资源
最近更新 更多