【发布时间】:2023-03-20 07:15:01
【问题描述】:
我有一个带有 5 个选项卡的 UITabBarController。我希望能够在所有选项卡上显示一个 ViewController,就在选项卡栏的上方。目前我遇到的问题是,当我以模态方式呈现 ViewController 时,它是不可见的。每当我在 tableView 中选择一行时,都会调用此函数:
调用showPlayerView的tableView定义如下:
class SearchResultsTableView: UIView, UITableViewDataSource, UITableViewDelegate
searchResultsTableView 类是另一个类中的视图,定义如下:
TestViewController: UIViewController, UserSearchDelegate, UISearchBarDelegate, UITableViewDelegate, UITableViewDataSource, UINavigationBarDelegate, UINavigationControllerDelegate
这是实际的功能:
func showPlayerView() {
let playerView = PlayerView()
playerView.modalPresentationStyle = .overCurrentContext
CustomTabBarController.sharedInstance?.present(playerView, animated: true, completion: {
})
}
然后我像这样设置 CustomTabBarController sharedInstance:
static var sharedInstance : CustomTabBarController?
在viewDidLoad() 里面我有这个:
CustomTabBarController.sharedInstance = self
为什么我看不到我的模态 ViewController,我怎样才能让它显示在所有屏幕上?
【问题讨论】:
-
您能否提供更多有关您在何处运行 showPlayerView 方法的背景信息?
-
刚刚编辑了问题并添加了正在运行的类
-
或许可以使用导航控制器?
-
但我需要它显示在我的 TabBarController 中的所有 5 个 VC 中。使用导航栏可以做到这一点吗?
-
显示更多代码和描述以便更好地理解以帮助您。
标签: ios swift uitabbarcontroller uimodalpresentationstyle