繁体   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