swift – iOS11如何通过滚动同步大型导航栏崩溃

swift – iOS11如何通过滚动同步大型导航栏崩溃,第1张

概述使用 Swift 3和Xcode 9我正在使用大型UINavigationBar视图: if #available(iOS 11.0, *) { navigationBar?.prefersLargeTitles = true UINavigationBar.appearance().largeTitleTextAttributes = [ NSForegrou 使用 Swift 3和Xcode 9我正在使用大型UINavigationbar视图:

if #available(iOS 11.0,*) {    navigationbar?.prefersLargeTitles = true    UINavigationbar.appearance().largeTitleTextAttributes = [        NSForegroundcolorAttributename: colors.black    ]}

滚动UItableVIEw时,条形图会快速折叠,从而产生不需要的空间:

之前:

后:

当我触摸UItableVIEw时,条形图会折叠.

tableVIEw具有以下属性:

let rect = CGRect(    x: 0,y: UIApplication.shared.statusbarVIEw?.frame.height ?? 20,wIDth: UIScreen.main.bounds.wIDth,height: UIScreen.main.bounds.height)let tableVIEw = UItableVIEw(frame: rect)

tableVIEw的顶部插图是self.navigationController?.navigationbar.frame.height ?? 44

tableVIEw也设置为:

if #available(iOS 11.0,*) {    self.contentInsetAdjustmentBehavior = .never}

酒吧是半透明的,我希望保持这一点.我错过了什么?非常感谢帮助.

解决方法 我不知道它对你有用.但它的示例代码对我有用.

class VIEwController: UIVIEwController,UItableVIEwDelegate,UItableVIEwDataSource,UISearchResultsUpdating {    var numbers: [String] = []    let rect = CGRect(        x: 0,y: UIApplication.shared.statusbarFrame.height ?? 20,height: UIScreen.main.bounds.height    )    lazy var tableVIEw: UItableVIEw = {        let tV = UItableVIEw()        tV.delegate = self        tV.dataSource = self        tV.register(UItableVIEwCell.classForCoder(),forCellReuseIDentifIEr: "cell")        return tV    }()    overrIDe func vIEwDIDLoad() {        super.vIEwDIDLoad()        numbers = generateNumbers()        self.vIEw.backgroundcolor = UIcolor.white        Title = "Numbers"        self.navigationController?.navigationbar.prefersLargeTitles = true        let search = UISearchController(searchResultsController: nil)        search.hIDesNavigationbarDuringPresentation = false        search.searchResultsUpdater = self        search.definesPresentationContext = true        self.navigationItem.searchController = search        tableVIEw.frame = rect        self.vIEw.addSubvIEw(tableVIEw)    }    func generateNumbers() -> [String] {        var numbers = [String]()        for var i in 1..<100 {            numbers.append(String(i))        }        return numbers    }    func numberOfSections(in tableVIEw: UItableVIEw) -> Int {        return 1    }    func tableVIEw(_ tableVIEw: UItableVIEw,numberOfRowsInSection section: Int) -> Int {        return numbers.count    }    func tableVIEw(_ tableVIEw: UItableVIEw,cellForRowAt indexPath: IndexPath) -> UItableVIEwCell {        let cell = tableVIEw.dequeueReusableCell(withIDentifIEr: "cell",for: indexPath)        cell.textLabel?.text = self.numbers[indexPath.row]        return cell    }    func tableVIEw(_ tableVIEw: UItableVIEw,dIDSelectRowAt indexPath: IndexPath) {        tableVIEw.deselectRow(at: indexPath,animated: true)    }    func updateSearchResults(for searchController: UISearchController) {        if let text = searchController.searchbar.text,!text.isEmpty {            numbers = self.numbers.filter({ (number) -> Bool in                return number.contains(text)            })        } else {            numbers = generateNumbers()        }        self.table.reloadData()    }}
总结

以上是内存溢出为你收集整理的swift – iOS11如何通过滚动同步大型导航栏崩溃全部内容,希望文章能够帮你解决swift – iOS11如何通过滚动同步大型导航栏崩溃所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1015863.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存