iOS 11 : Cellular Signal strength

你离开我真会死。 提交于 2019-12-21 21:15:07

问题


I was fetching Cellular Signal Strength(iOS < 11) as mentioned below, but in iOS 11 , signalStrength is always 0

  let statusBarView = UIApplication.shared.value(forKey: "statusBar") as? UIView
            if let foregroundView = statusBarView?.value(forKey: "foregroundView") as? UIView {
                let subiews = foregroundView.subviews
                var dataNetworkItemView:UIView?
                for subview in subiews {
                    if subview.isKind(of: NSClassFromString("UIStatusBarSignalStrengthItemView")!) == true {
                        dataNetworkItemView = subview
                        break
                    }
                }
                var signalStrength = 0
                var signalStrengthBars = 0
                if let view = dataNetworkItemView {
                    signalStrength = view.value(forKey: "signalStrengthRaw") as! Int
                    signalStrengthBars = view.value(forKey: "signalStrengthBars") as! Int
                }

来源:https://stackoverflow.com/questions/46462712/ios-11-cellular-signal-strength

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!