EvenLoop模型在iOS的RunLoop應(yīng)用示例
引言
Runloop在iOS中是一個(gè)很重要的組成部分,對(duì)于任何單線程的UI模型都必須使用EvenLoop才可以連續(xù)處理不同的事件,而RunLoop就是EvenLoop模型在iOS中的實(shí)現(xiàn)。在前面的幾篇文章中,我已經(jīng)介紹了Runloop的底層原理等,這篇文章主要是從實(shí)際開(kāi)發(fā)的角度,探討一下實(shí)際上在哪些場(chǎng)景下,我們可以去使用RunLoop。
線程?;?/h2>
在實(shí)際開(kāi)發(fā)中,我們通常會(huì)遇到常駐線程的創(chuàng)建,比如說(shuō)發(fā)送心跳包,這就可以在一個(gè)常駐線程來(lái)發(fā)送心跳包,而不干擾主線程的行為,再比如音頻處理,這也可以在一個(gè)常駐線程中來(lái)處理。以前在Objective-C中使用的AFNetworking 1.0就使用了RunLoop來(lái)進(jìn)行線程的?;?。
var thread: Thread! func createLiveThread() { thread = Thread.init(block: { let port = NSMachPort.init() RunLoop.current.add(port, forMode: .default) RunLoop.current.run() }) thread.start() }
值得注意的是RunLoop的mode中至少需要一個(gè)port/timer/observer,否則RunLoop只會(huì)執(zhí)行一次就退出了。
停止Runloop
離開(kāi)RunLoop一共有兩種方法:其一是給RunLoop配置一個(gè)超時(shí)的時(shí)間,其二是主動(dòng)通知RunLoop離開(kāi)。Apple在文檔中是推薦第一種方式的,如果能直接定量的管理,這種方式當(dāng)然是最好的。
設(shè)置超時(shí)時(shí)間
然而實(shí)際中我們無(wú)法準(zhǔn)確的去設(shè)置超時(shí)的時(shí)刻,比如在線程?;畹睦又?,我們需要保證線程的RunLoop一直保持運(yùn)行中,所以結(jié)束的時(shí)間是一個(gè)變量,而不是常量,要達(dá)到這個(gè)目標(biāo)我們可以結(jié)合一下RunLoop提供的API,在開(kāi)始的時(shí)候,設(shè)置RunLoop超時(shí)時(shí)間為無(wú)限,但是在結(jié)束時(shí),設(shè)置RunLoop超時(shí)時(shí)間為當(dāng)前,這樣變相通過(guò)控制timeout的時(shí)間停止了RunLoop,具體代碼如下:
var thread: Thread? var isStopped: Bool = false func createLiveThread() { thread = Thread.init(block: { [weak self] in guard let self = self else { return } let port = NSMachPort.init() RunLoop.current.add(port, forMode: .default) while !self.isStopped { RunLoop.current.run(mode: .default, before: Date.distantFuture) } }) thread?.start() } func stop() { self.perform(#selector(self.stopThread), on: thread!, with: nil, waitUntilDone: false) } @objc func stopThread() { self.isStopped = true RunLoop.current.run(mode: .default, before: Date.init()) self.thread = nil }
直接停止
CoreFoundation提供了API:CFRunLoopStop()
但是這個(gè)方法只會(huì)停止當(dāng)前這次循環(huán)的RunLoop,并不會(huì)完全停止RunLoop。那么有沒(méi)有其它的策略呢?我們知道RunLoop的Mode中必須要至少有一個(gè)port/timer/observer才會(huì)工作,否則就會(huì)退出,而CF提供的API中正好有:
**public func CFRunLoopRemoveSource(_ rl: CFRunLoop!, _ source: CFRunLoopSource!, _ mode: CFRunLoopMode!) public func CFRunLoopRemoveObserver(_ rl: CFRunLoop!, _ observer: CFRunLoopObserver!, _ mode: CFRunLoopMode!) public func CFRunLoopRemoveTimer(_ rl: CFRunLoop!, _ timer: CFRunLoopTimer!, _ mode: CFRunLoopMode!)**
所以很自然的聯(lián)想到如果移除source/timer/observer, 那么這個(gè)方案可不可以停止RunLoop呢?
答案是否定的,這一點(diǎn)在Apple的官方文檔中有比較詳細(xì)的描述:
Although removing a run loop’s input sources and timers may also cause the run loop to exit, this is not a reliable way to stop a run loop. Some system routines add input sources to a run loop to handle needed events. Because your code might not be aware of these input sources, it would be unable to remove them, which would prevent the run loop from exiting.
簡(jiǎn)而言之,就是你無(wú)法保證你移除的就是全部的source/timer/observer,因?yàn)橄到y(tǒng)可能會(huì)添加一些必要的source來(lái)處理事件,而這些source你是無(wú)法確保移除的。
延遲加載圖片
這是一個(gè)很常見(jiàn)的使用方式,因?yàn)槲覀冊(cè)诨瑒?dòng)scrollView/tableView/collectionView的過(guò)程,總會(huì)給cell設(shè)置圖片,但是直接給cell的imageView設(shè)置圖片的過(guò)程中,會(huì)涉及到圖片的解碼操作,這個(gè)就會(huì)占用CPU的計(jì)算資源,可能導(dǎo)致主線程發(fā)生卡頓,所以這里可以將這個(gè)操作,不放在trackingMode,而是放在defaultMode中,通過(guò)一種取巧的方式來(lái)解決可能的性能問(wèn)題。
func setupImageView() { self.performSelector(onMainThread: #selector(self.setupImage), with: nil, waitUntilDone: false, modes: [RunLoop.Mode.default.rawValue]) } @objc func setupImage() { imageView.setImage() }
卡頓監(jiān)測(cè)
目前來(lái)說(shuō),一共有三種卡頓監(jiān)測(cè)的方案,然而基本上每一種卡頓監(jiān)測(cè)的方案都和RunLoop是有關(guān)聯(lián)的。
CADisplayLink(FPS)
YYFPSLabel 采用的就是這個(gè)方案,F(xiàn)PS(Frames Per Second)代表每秒渲染的幀數(shù),一般來(lái)說(shuō),如果App的FPS保持50~60之間,用戶(hù)的體驗(yàn)就是比較流暢的,但是Apple自從iPhone支持120HZ的高刷之后,它發(fā)明了一種ProMotion的動(dòng)態(tài)屏幕刷新率的技術(shù),這種方式基本就不能使用了,但是這里依舊提供已作參考。
這里值得注意的技術(shù)細(xì)節(jié)是使用了NSObject來(lái)做方法的轉(zhuǎn)發(fā),在OC中可以使用NSProxy來(lái)做消息的轉(zhuǎn)發(fā),效率更高。
// 抽象的超類(lèi),用來(lái)充當(dāng)其它對(duì)象的一個(gè)替身 // Timer/CADisplayLink可以使用NSProxy做消息轉(zhuǎn)發(fā),可以避免循環(huán)引用 // swift中我們是沒(méi)發(fā)使用NSInvocation的,所以我們直接使用NSobject來(lái)做消息轉(zhuǎn)發(fā) class WeakProxy: NSObject { private weak var target: NSObjectProtocol? init(target: NSObjectProtocol) { self.target = target super.init() } override func responds(to aSelector: Selector!) -> Bool { return (target?.responds(to: aSelector) ?? false) || super.responds(to: aSelector) } override func forwardingTarget(for aSelector: Selector!) -> Any? { return target } } class FPSLabel: UILabel { var link: CADisplayLink! var count: Int = 0 var lastTime: TimeInterval = 0.0 fileprivate let defaultSize = CGSize.init(width: 80, height: 20) override init(frame: CGRect) { super.init(frame: frame) if frame.size.width == 0 || frame.size.height == 0 { self.frame.size = defaultSize } layer.cornerRadius = 5.0 clipsToBounds = true textAlignment = .center isUserInteractionEnabled = false backgroundColor = UIColor.white.withAlphaComponent(0.7) link = CADisplayLink.init(target: WeakProxy.init(target: self), selector: #selector(FPSLabel.tick(link:))) link.add(to: RunLoop.main, forMode: .common) } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } deinit { link.invalidate() } @objc func tick(link: CADisplayLink) { guard lastTime != 0 else { lastTime = link.timestamp return } count += 1 let timeDuration = link.timestamp - lastTime // 1、設(shè)置刷新的時(shí)間: 這里是設(shè)置為1秒(即每秒刷新) guard timeDuration >= 1.0 else { return } // 2、計(jì)算當(dāng)前的FPS let fps = Double(count)/timeDuration count = 0 lastTime = link.timestamp // 3、開(kāi)始設(shè)置FPS了 let progress = fps/60.0 let color = UIColor(hue: CGFloat(0.27 * (progress - 0.2)), saturation: 1, brightness: 0.9, alpha: 1) self.text = "\(Int(round(fps))) FPS" self.textColor = color } }
子線程Ping
這種方法是創(chuàng)建了一個(gè)子線程,通過(guò)GCD給主線程添加異步任務(wù):修改是否超時(shí)的參數(shù),然后讓子線程休眠一段時(shí)間,如果休眠的時(shí)間結(jié)束之后,超時(shí)參數(shù)未修改,那說(shuō)明給主線程的任務(wù)并沒(méi)有執(zhí)行,那么這就說(shuō)明主線程的上一個(gè)任務(wù)還沒(méi)有做完,那就說(shuō)明卡頓了,這種方式其實(shí)和RunLoop沒(méi)有太多的關(guān)聯(lián),它不依賴(lài)RunLoop的狀態(tài)。在ANREye中是采用子線程Ping的方式來(lái)監(jiān)測(cè)卡頓的。
同時(shí)為了讓這些操作是同步的,這里使用了信號(hào)量。
class PingMonitor { static let timeoutInterval: TimeInterval = 0.2 static let queueIdentifier: String = "com.queue.PingMonitor" private var queue: DispatchQueue = DispatchQueue.init(label: queueIdentifier) private var isMonitor: Bool = false private var semphore: DispatchSemaphore = DispatchSemaphore.init(value: 0) func startMonitor() { guard isMonitor == false else { return } isMonitor = true queue.async { while self.isMonitor { var timeout = true DispatchQueue.main.async { timeout = false self.semphore.signal() } Thread.sleep(forTimeInterval:PingMonitor.timeoutInterval) // 說(shuō)明等了timeoutInterval之后,主線程依然沒(méi)有執(zhí)行派發(fā)的任務(wù),這里就認(rèn)為它是處于卡頓的 if timeout == true { //TODO: 這里需要取出崩潰方法棧中的符號(hào)來(lái)判斷為什么出現(xiàn)了卡頓 // 可以使用微軟的框架:PLCrashReporter } self.semphore.wait() } } } }
這個(gè)方法在正常情況下會(huì)每隔一段時(shí)間讓主線程執(zhí)行GCD派發(fā)的任務(wù),會(huì)造成部分資源的浪費(fèi),而且它是一種主動(dòng)的去Ping主線程,并不能很及時(shí)的發(fā)現(xiàn)卡頓問(wèn)題,所以這種方法會(huì)有一些缺點(diǎn)。
實(shí)時(shí)監(jiān)控
而我們知道,主線程中任務(wù)都是通過(guò)RunLoop來(lái)管理執(zhí)行的,所以我們可以通過(guò)監(jiān)聽(tīng)RunLoop的狀態(tài)來(lái)知道是否會(huì)出現(xiàn)卡頓的情況,一般來(lái)說(shuō),我們會(huì)監(jiān)測(cè)兩種狀態(tài):第一種是kCFRunLoopAfterWaiting
的狀態(tài),第二種是kCFRunLoopBeforeSource
的狀態(tài)。為什么是兩種狀態(tài)呢?
首先看第一種狀態(tài)kCFRunLoopAfterWaiting
,它會(huì)在RunLoop被喚醒之后回調(diào)這種狀態(tài),然后根據(jù)被喚醒的端口來(lái)處理不同的任務(wù),如果處理任務(wù)的過(guò)程中耗時(shí)過(guò)長(zhǎng),那么下一次檢查的時(shí)候,它依然是這個(gè)狀態(tài),這個(gè)時(shí)候就可以說(shuō)明它卡在了這個(gè)狀態(tài)了,然后可以通過(guò)一些策略來(lái)提取出方法棧,來(lái)判斷卡頓的代碼。同理,第二種狀態(tài)也是一樣的,說(shuō)明一直處于kCFRunLoopBeforeSource
狀態(tài),而沒(méi)有進(jìn)入下一狀態(tài)(即休眠),也發(fā)生了卡頓。
class RunLoopMonitor { private init() {} static let shared: RunLoopMonitor = RunLoopMonitor.init() var timeoutCount = 0 var runloopObserver: CFRunLoopObserver? var runLoopActivity: CFRunLoopActivity? var dispatchSemaphore: DispatchSemaphore? // 原理:進(jìn)入睡眠前方法的執(zhí)行時(shí)間過(guò)長(zhǎng)導(dǎo)致無(wú)法進(jìn)入睡眠,或者線程喚醒之后,一直沒(méi)進(jìn)入下一步 func beginMonitor() { let uptr = Unmanaged.passRetained(self).toOpaque() let vptr = UnsafeMutableRawPointer(uptr) var context = CFRunLoopObserverContext.init(version: 0, info: vptr, retain: nil, release: nil, copyDescription: nil) runloopObserver = CFRunLoopObserverCreate(kCFAllocatorDefault, CFRunLoopActivity.allActivities.rawValue, true, 0, observerCallBack(), &context) CFRunLoopAddObserver(CFRunLoopGetMain(), runloopObserver, .commonModes) // 初始化的信號(hào)量為0 dispatchSemaphore = DispatchSemaphore.init(value: 0) DispatchQueue.global().async { while true { // 方案一:可以通過(guò)設(shè)置單次超時(shí)時(shí)間來(lái)判斷 比如250毫秒 // 方案二:可以通過(guò)設(shè)置連續(xù)多次超時(shí)就是卡頓 戴銘在GCDFetchFeed中認(rèn)為連續(xù)三次超時(shí)80秒就是卡頓 let st = self.dispatchSemaphore?.wait(timeout: DispatchTime.now() + .milliseconds(80)) if st == .timedOut { guard self.runloopObserver != nil else { self.dispatchSemaphore = nil self.runLoopActivity = nil self.timeoutCount = 0 return } if self.runLoopActivity == .afterWaiting || self.runLoopActivity == .beforeSources { self.timeoutCount += 1 if self.timeoutCount < 3 { continue } DispatchQueue.global().async { let config = PLCrashReporterConfig.init(signalHandlerType: .BSD, symbolicationStrategy: .all) guard let crashReporter = PLCrashReporter.init(configuration: config) else { return } let data = crashReporter.generateLiveReport() do { let reporter = try PLCrashReport.init(data: data) let report = PLCrashReportTextFormatter.stringValue(for: reporter, with: PLCrashReportTextFormatiOS) ?? "" NSLog("------------卡頓時(shí)方法棧:\n \(report)\n") } catch _ { NSLog("解析crash data錯(cuò)誤") } } } } } } } func end() { guard let _ = runloopObserver else { return } CFRunLoopRemoveObserver(CFRunLoopGetMain(), runloopObserver, .commonModes) runloopObserver = nil } private func observerCallBack() -> CFRunLoopObserverCallBack { return { (observer, activity, context) in let weakself = Unmanaged<RunLoopMonitor>.fromOpaque(context!).takeUnretainedValue() weakself.runLoopActivity = activity weakself.dispatchSemaphore?.signal() } } }
Crash防護(hù)
Crash防護(hù)是一個(gè)很有意思的點(diǎn),處于應(yīng)用層的APP,在執(zhí)行了某些不被操作系統(tǒng)允許的操作之后會(huì)觸發(fā)操作系統(tǒng)拋出異常信號(hào),但是因?yàn)闆](méi)有處理這些異常從而被系操作系統(tǒng)殺掉的線程,比如常見(jiàn)的閃退。這里不對(duì)Crash做詳細(xì)的描述,我會(huì)在下一個(gè)模塊來(lái)描述iOS中的異常。要明確的是,有些場(chǎng)景下,是希望可以捕獲到系統(tǒng)拋出的異常,然后將App從錯(cuò)誤中恢復(fù),重新啟動(dòng),而不是被殺死。而對(duì)應(yīng)在代碼中,我們需要去手動(dòng)的重啟主線程,已達(dá)到繼續(xù)運(yùn)行App的目的。
let runloop = CFRunLoopGetCurrent() guard let allModes = CFRunLoopCopyAllModes(runloop) as? [CFRunLoopMode] else { return } while true { for mode in allModes { CFRunLoopRunInMode(mode, 0.001, false) } }
CFRunLoopRunInMode(mode, 0.001, false)
因?yàn)闊o(wú)法確定RunLoop到底是怎樣啟動(dòng)的,所以采用了這種方式來(lái)啟動(dòng)RunLoop的每一個(gè)Mode,也算是一種替代方案了。因?yàn)?code>CFRunLoopRunInMode 在運(yùn)行的時(shí)候本身就是一個(gè)循環(huán)并不會(huì)退出,所以while循環(huán)不會(huì)一直執(zhí)行,只是在mode退出之后,while循環(huán)遍歷需要執(zhí)行的mode,直到繼續(xù)在一個(gè)mode中常駐。
這里只是重啟RunLoop,其實(shí)在Crash防護(hù)里最重要的還是要監(jiān)測(cè)到何時(shí)發(fā)送崩潰,捕獲系統(tǒng)的exception信息,以及singal信息等等,捕獲到之后再對(duì)當(dāng)前線程的方法棧進(jìn)行分析,定位為crash的成因。
Matrix框架
接下來(lái)我們具體看一下RunLoop在Matrix框架中的運(yùn)用。Matrix是騰訊開(kāi)源的一款用于性能監(jiān)測(cè)的框架,在這個(gè)框架中有一款插件**WCFPSMonitorPlugin
:**這是一款FPS監(jiān)控工具,當(dāng)用戶(hù)滑動(dòng)界面時(shí),記錄主線程的調(diào)用棧。它的源碼中和我們上述提到的通過(guò)CADisplayLink
來(lái)來(lái)監(jiān)測(cè)卡頓的方案的原理是一樣的:
- (void)startDisplayLink:(NSString *)scene { FPSInfo(@"startDisplayLink"); m_displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(onFrameCallback:)]; [m_displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes]; ... } - (void)onFrameCallback:(id)sender { // 當(dāng)前時(shí)間: 單位為秒 double nowTime = CFAbsoluteTimeGetCurrent(); // 將單位轉(zhuǎn)化為毫秒 double diff = (nowTime - m_lastTime) * 1000; // 1、如果時(shí)間間隔超過(guò)最大的幀間隔:那么此次屏幕刷新方法超時(shí) if (diff > self.pluginConfig.maxFrameInterval) { m_currRecorder.dumpTimeTotal += diff; m_dropTime += self.pluginConfig.maxFrameInterval * pow(diff / self.pluginConfig.maxFrameInterval, self.pluginConfig.powFactor); // 總超時(shí)時(shí)間超過(guò)閾值:展示超時(shí)信息 if (m_currRecorder.dumpTimeTotal > self.pluginConfig.dumpInterval * self.pluginConfig.dumpMaxCount) { FPSInfo(@"diff %lf exceed, begin: %lf, end: %lf, scene: %@, you can see more detail in record id: %d", m_currRecorder.dumpTimeTotal, m_currRecorder.dumpTimeBegin, m_currRecorder.dumpTimeBegin + m_currRecorder.dumpTimeTotal / 1000.0, m_scene, m_currRecorder.recordID); ...... } // 2、如果時(shí)間間隔沒(méi)有最大的幀間隔:那么此次屏幕刷新方法不超時(shí) } else { // 總超時(shí)時(shí)間超過(guò)閾值:展示超時(shí)信息 if (m_currRecorder.dumpTimeTotal > self.pluginConfig.maxDumpTimestamp) { FPSInfo(@"diff %lf exceed, begin: %lf, end: %lf, scene: %@, you can see more detail in record id: %d", m_currRecorder.dumpTimeTotal, m_currRecorder.dumpTimeBegin, m_currRecorder.dumpTimeBegin + m_currRecorder.dumpTimeTotal / 1000.0, m_scene, m_currRecorder.recordID); .... // 總超時(shí)時(shí)間不超過(guò)閾值:將時(shí)間歸0 重新計(jì)數(shù) } else { m_currRecorder.dumpTimeTotal = 0; m_currRecorder.dumpTimeBegin = nowTime + 0.0001; } } m_lastTime = nowTime; }
它通過(guò)次數(shù)以及兩次之間允許的時(shí)間間隔作為閾值,超過(guò)閾值就記錄,沒(méi)超過(guò)閾值就歸0重新計(jì)數(shù)。當(dāng)然這個(gè)框架也不僅僅是作為一個(gè)簡(jiǎn)單的卡頓監(jiān)測(cè)來(lái)使用的,還有很多性能監(jiān)測(cè)的功能以供平時(shí)開(kāi)發(fā)的時(shí)候來(lái)使用:包括對(duì)崩潰時(shí)方法棧的分析等等。
總結(jié)
本篇文章我從線程?;铋_(kāi)始介紹了RunLoop在實(shí)際開(kāi)發(fā)中的使用,然后主要是介紹了卡頓監(jiān)測(cè)和Crash防護(hù)中的高階使用,當(dāng)然,RunLoop的運(yùn)用遠(yuǎn)不止這些,如果有更多更好的使用,希望大家可以留言交流。
以上就是EvenLoop模型在iOS的RunLoop應(yīng)用示例的詳細(xì)內(nèi)容,更多關(guān)于ios EvenLoop模型RunLoop的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
Swift 4中一些實(shí)用的數(shù)組技巧小結(jié)
這篇文章主要給大家分享了關(guān)于Swift 4中一些實(shí)用的數(shù)組技巧,文中通過(guò)示例代碼介紹的介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用swift具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧。2018-03-03Swift網(wǎng)絡(luò)請(qǐng)求庫(kù)Alamofire使用詳解
這篇文章主要為大家詳細(xì)介紹了Swift網(wǎng)絡(luò)請(qǐng)求庫(kù)Alamofire的使用方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-08-08Swift設(shè)計(jì)思想Result<T>與Result<T,?E:?Error>類(lèi)型解析
這篇文章主要為大家介紹了Swift設(shè)計(jì)思想Result<T>與Result<T,?E:?Error>的類(lèi)型示例解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-11-11Swift實(shí)現(xiàn)表格視圖單元格單選(1)
這篇文章主要為大家詳細(xì)介紹了Swift實(shí)現(xiàn)表格視圖單元格單選,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-01-01深入解析Swift中switch語(yǔ)句對(duì)case的數(shù)據(jù)類(lèi)型匹配的支持
這篇文章主要介紹了Swift中switch語(yǔ)句對(duì)case的數(shù)據(jù)類(lèi)型匹配的支持,Swift中switch...case語(yǔ)句支持多種數(shù)據(jù)類(lèi)型的匹配判斷,十分強(qiáng)大,需要的朋友可以參考下2016-04-04Swift算法實(shí)現(xiàn)字符串轉(zhuǎn)數(shù)字的方法示例
最近學(xué)完了swift想著實(shí)踐下,就通過(guò)一些簡(jiǎn)單的算法進(jìn)行學(xué)習(xí)研究,下面這篇文章主要介紹了Swift算法實(shí)現(xiàn)字符串轉(zhuǎn)數(shù)字的方法,需要的朋友可以參考借鑒,下面來(lái)一起看看吧。2017-03-03Swift map和filter函數(shù)原型基礎(chǔ)示例
這篇文章主要為大家介紹了Swift map和filter函數(shù)原型基礎(chǔ)示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-07-07RxSwift學(xué)習(xí)教程之類(lèi)型對(duì)象Subject詳解
這篇文章主要給大家介紹了關(guān)于RxSwift學(xué)習(xí)教程之類(lèi)型對(duì)象Subject的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起看看吧。2017-09-09