swift
1var articles: [ArticleViewController] = [] 2 var keepAlive = true 3 let runLoop = RunLoop.current 4 Alamofire.request(Constant.Url.categoryUrl, method: .get, encoding: JSONEncoding.default).responseJSON { response in 5 switch response.result { 6 case .success: 7 guard let object = response.result.value else { return } 8 let json:JSON = JSON(object) 9 json.forEach { (_, json) in 10 self.categories.append(json["name"].stringValue) 11 self.categoriesId.append(json["id"].stringValue) 12 } 13 case .failure: 14 print("error") 15 } 16 keepAlive = false 17 } 18 while keepAlive && 19 runLoop.run(mode: RunLoopMode.defaultRunLoopMode, before: NSDate(timeIntervalSinceNow: 0.1) as Date) { 20 21 } 22 for i in 0..<categories.count { 23 articles.append(ArticleViewController()) 24 articles[i].categoryInfo = IndicatorInfo(title: categories[i]) 25 } 26 return articles 27 }
上記のようなコードを書いて、alamofireでのデータの取得が終わるまで、一定時間待つようなコードを書いたのですが、待ち時間は一瞬なのですが、その一瞬画面が真っ黒になってしまいます。UX的に最もよい対処法があれば教えてください。
よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2018/07/01 14:27