簡體   English   中英

嘗試使用Multipeer Connectivity Swift 3 Xcode8傳遞UIALERT時出現多個錯誤

[英]Multiple errors when trying to pass UIALERT using Multipeer Connectivity Swift 3 Xcode8

我想知道此時我的代碼有什么問題。 嘗試了很多之后,我想出了如何將UIAlert傳遞給……種類。但是我遇到了錯誤。 另一雙眼睛會很好地建議您。 源代碼會很棒。 在此先感謝代碼如下。 我只是放入了我需要轉移的部分代碼。 我還沒有寫完“ didfinishRecievingResource”; 因為我被困在這一點上。 如果無法做到這一點,您能告訴我我可以改行嗎。 再次感謝您關注此內容。 我也在使用xcode8。謝謝多人連接

    func session(_ session: MCSession, didStartReceivingResourceWithName resourceName: String, fromPeer peerID: MCPeerID, with progress: Progress) {
   self.newAlert(title: "HI", message: "Player 1 !")


  func newAlert (title: String, message:String)
 {
      let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: output.text, style: UIAlertActionStyle.default, handler: { (action) in

}))
self.present(alert,animated: true, completion:nil)

}

}

}

如下更改您的UIAlert

// alert box
    func newAlert(title: String, message: String) {

        let alertController = UIAlertController(title: title, message:
            message, preferredStyle: UIAlertControllerStyle.alert)

        alertController.addAction(UIAlertAction(title: output.text, style: UIAlertActionStyle.default,handler: nil))

        self.present(alertController, animated: true, completion: nil)
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM