Tencent / QMUI_iOS

QMUI iOS——致力于提高项目 UI 开发效率的解决方案
http://qmuiteam.com/ios
Other
7.09k stars 1.38k forks source link

QMUISearchController的searchBar没有挡住状态栏 #610

Closed kj-love-xj closed 5 years ago

kj-love-xj commented 5 years ago

Bug 表现 问题的具体描述 搜索框进入编辑时,状态栏是一个黑色半透明遮罩,内容向上滑动时,内容会显示在状态栏上

截图 Bug 现场的界面截图,或者 Xcode 控制台的错误信息截图,有问题的代码截图 IMG_BC931DFCD446-1

如何重现

  1. ...
  2. ...

预期的表现 正常情况下,应该是什么表现 正常情况下,搜索框应该盖住状态栏

其他信息

MoLice commented 5 years ago

请贴出具体代码

kj-love-xj commented 5 years ago

请贴出具体代码

使用的就是QMUICommonTableViewController,不知道与FDFullscreenPopGesture有没有关系

`override func viewDidLoad() { super.viewDidLoad() title = "邀请好友" // 显示搜索框 shouldShowSearchBar = true // 搜索框的颜色 searchBar.backgroundImage = UIImage(color: UIColor.white) // 返回按钮 useBackBarButtonItem() tableView.backgroundColor = UIColor(rgb: 0xF5F7F9) tableView.separatorStyle = .none searchController.tableView.backgroundColor = UIColor(rgb: 0xF5F7F9) searchController.tableView.separatorStyle = .none

    tableView.register(JOINIMInviteUserViewCell.self, forCellReuseIdentifier: "JOINIMInviteUserViewCell")
    searchController.tableView.register(JOINIMInviteUserViewCell.self, forCellReuseIdentifier: "JOINIMInviteUserViewCell")
    if group_id == nil {
        if group != nil {
            group_id = group!.group_id
        }
    }
    (btnConfirm.rx.tap)
        .throttle(kjButtonActionSpace, latest: false, scheduler: MainScheduler.instance)
        .subscribe(onNext: {
            [weak self] in
            // 确定邀请进群
            self?.invite()
        }).disposed(by: dispose)

    // 获取好友列表
    getUserFriends()
}`

下面是搜索的代码

`/// 搜索 override func searchController(_ searchController: QMUISearchController!, updateResultsForSearch searchString: String!) { guard searchString.isEmpty == false else { searchArray.removeAll() searchController.tableView.reloadData() return } let data = (dataArray as NSArray).filtered(using: NSPredicate(format: "name like[cd] '(searchString!)'")) searchArray.removeAll() if data.count > 0 { searchArray.append(contentsOf: (data as! Array)) } searchController.tableView.reloadData() }

override func willPresent(_ searchController: QMUISearchController!) {
    setNeedsStatusBarAppearanceUpdate()
}

override func willDismiss(_ searchController: QMUISearchController!) {
    setNeedsStatusBarAppearanceUpdate()
}`
MoLice commented 5 years ago

看不出来是什么问题,可以尝试换种设置背景图的方式,例如 UISearchBar.m:388-389 的写法。

或者提供一份有问题的 Demo。

kj-love-xj commented 5 years ago

看不出来是什么问题,可以尝试换种设置背景图的方式,例如 UISearchBar.m:388-389 的写法。

或者提供一份有问题的 Demo。

找到问题了,是因为edgesForExtendedLayout = UIRectEdgeNone导致的。。

Goallying commented 3 years ago

我也有这个问题,edgesForExtendedLayout 没有设置。。。