2017-08-31 67 views
0

我的代碼爲ActionSheet它有點慢,它可以連接什麼?ActionSheet滯後

@IBAction func showAction(_ sender: UIButton) { 
    let actionSheetController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet) 
    actionSheetController.addAction(
     UIAlertAction(title: NSLocalizedString("Copy", comment: ""), style: .default, handler: { [weak self] _ in 
      guard let strongSelf = self else { return } 

      UIPasteboard.general.string = strongSelf.displayResultLabel.text 

      let alert = UIAlertController(title: NSLocalizedString("Copied to clipboard", comment: ""), message: "", preferredStyle: .alert) 
      let when = DispatchTime.now() + 0.5 
      DispatchQueue.main.asyncAfter(deadline: when){ 
       alert.dismiss(animated: true, completion: nil) 
      } 
      self?.present(alert, animated: true, completion:nil) 
     }) 
    ) 
    actionSheetController.addAction(UIAlertAction(title: NSLocalizedString("Cancel", comment: ""), style: .cancel, handler: nil)) 

    present(actionSheetController, animated: true, completion: nil) 
} 
+0

它是什麼,它可以連接有點慢 - 其中之一出席或辭退 –

+0

@ Anbu.Karthik哪一個 當下 – BLC

回答

1

變化animated: true

present(actionSheetController, animated: true, completion: nil) 

animated: false爲省略延遲或動畫

present(actionSheetController, animated: false, completion: nil)