私はUIAlertで多くの遅延があります。ロードするたびに、クリックする前に待ってからもう一度、完全に消えるようにしてください。私はdispatch_async(dispatch_get_main_queue(), {})
を使って推薦する他の答えを見ました。私はこれを使用しようとしましたが、無駄です。私が作っているシーンキットゲームのレンダーループ中に警告がポップアップします(シーンはキューブだけで、シーンを一時停止するとまだ遅れています)。とにかくレンダリングスレッドでレンダリングしないでください。私は何かがメインスレッドをブロックしていたかどうかを見るために時間プロファイルのログを見ましたが、私は注意を引いたものは見ませんでした。遅延を表示するUIAlertController
func share(){
print("share funciton")
let alert = UIAlertController(title: "Share", message: "Where do you want to share?", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "Twitter", style: .Default, handler: {(alert: UIAlertAction!) in
print("twitter")
self.showTwitter()
}))
self.presentViewController(alert, animated: false, completion: nil)
}
private func showTwitter() {
if SLComposeViewController.isAvailableForServiceType(SLServiceTypeTwitter) {
let tweetShare:SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeTwitter)
self.presentViewController(tweetShare, animated: true, completion: nil)
} else {
let alert = UIAlertController(title: "Accounts", message: "Please login to a Twitter account to tweet.", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
}
}
その後、私は呼んでシェア()ときdispatch_asychとレンダリングループ内:
は、ここで私は、アラートを作成しています私のコードです。私はこのバグで3日間働いていましたが、遅れを引き起こす原因は何もわかりません。
シミュレータまたはデバイス? – Wain
シミュレータ内 – egdenis
誤って低速アニメーションがオンになっていますか? – Wain