gpt4 book ai didi

ios - 如何将导航栏和标签栏设置为通过 UIPopoverViewController 的 View ?

转载 作者:行者123 更新时间:2023-11-28 07:55:28 26 4
gpt4 key购买 nike

我将 UIViewController 自定义为 PopoverViewController,当我展示它时,我无法触摸导航栏和标签栏

我搜索了一会儿,得到了:在第一个 ViewController 代码的准备中(对于 segue:UIStoryboardSegue,发件人:Any?):

if segue.identifier == "ShowChoice"{
let poper = segue.destination
poper.modalPresentationStyle = .popover
poper.popoverPresentationController?.delegate = self
let point = CGPoint(x: self.view.bounds.midX, y: self.view.bounds.midY + 5)
poper.popoverPresentationController?.sourceView = self.view
poper.popoverPresentationController?.sourceRect = CGRect(origin: point, size: CGSize.zero)
poper.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection(rawValue: 0)

//here I set [self.view] to passthroughViews and it work i can interact with all thing in self.view but I can't interact with Navigation Button or Tab bar item!

poper.popoverPresentationController?.passthroughViews = [self.view]
}
}

我只能将 UIView 设置为 passthroughViews 但我想设置 Navigation Bar 或 Tab Bar

谢谢!

最佳答案

有趣的是,popoverPresentationController.passthroughViews 中项目的顺序很重要!

例如,如果你想添加所有 View 和导航栏,你必须将导航栏放在列表的开头,否则触摸将被馈送到它下面的任何项目

这是我的代码:

 popoverPresentationController.passthroughViews = [self.view]
if let navBar = self.navigationController?.navigationBar {
popoverPresentationController.passthroughViews?.insert(navBar, at: 0)
}

此外,如果您这样做是为了能够使用后退按钮,请记住关闭 popoverView

关于ios - 如何将导航栏和标签栏设置为通过 UIPopoverViewController 的 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48219854/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com