我有一个简单的应用程序,我在其中运行一些GET查询并在完成后触发模态视图。呈现视图控制器包含带有搜索控制器/搜索栏的地图视图。当触发模态时,它会按预期显示overCurrentContext(带有模糊效果),但导航栏(带有取消按钮)会在搜索栏下方滑动。我可以看到导航栏已正确创建(带有标题和取消按钮),但它会在搜索栏下方转换。我做错了什么吗?
呈现viewController
func showPopOver() {
let fares = Fares(userLocation: userLocation, destination: userDestination)
fares.getFares { _ in
self.RideCosts = self.storyboard!.instantiateViewController(withIdentifier: "RideCosts") as! RideCosts
self.RideCosts.modalPresentationStyle = .overCurrentContext
self.RideCosts.loadFares(fares: fares.fareArray)
self.present(self.RideCosts, animated: true, completion: nil)
}
}
modalViewController(RideCosts)
class RideCosts: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet weak var tableView: UITableView!
@IBAction func cancel(_ sender: UIBarButtonItem) {
dismiss(animated: true, completion: nil)
}
var fareArray: [(name: String, value: String)] = []
var arrayOfCellData = [cellData]()
override func viewDidLoad() {
super.viewDidLoad()
let blurEffect = UIBlurEffect(style: .extraLight)
let blurEffectView = UIVisualEffectView(effect: blurEffect)
blurEffectView.frame = self.view.frame
self.view.insertSubview(blurEffectView, at: 0)
self.view.backgroundColor = UIColor.clear
self.modalTransitionStyle = .crossDissolve
self.isModalInPopover = true
tableView.delegate = self
tableView.dataSource = self
}
答案 0 :(得分:0)
回到这个...... Swift菜鸟错误,我通过将modalpresentationStyle设置为overFullScreen而不是overCurrentContext
解决了模态演示(模式视图&在搜索栏下方显示的导航栏)的问题工作代码
func showPopOver() {
let fares = Fares(userLocation: userLocation, destination: userDestination)
fares.getFares { _ in
self.RideCosts = self.storyboard!.instantiateViewController(withIdentifier: "RideCosts") as! RideCosts
self.RideCosts.modalPresentationStyle = .overCurrentContext //FIX
self.RideCosts.loadFares(fares: fares.fareArray)
self.present(self.RideCosts, animated: true, completion: nil)
}
}