このコードを使用すると、プロジェクトのすべてのビューに警告が表示されます。例については
let imageView = UIImageView(frame: CGRectMake(70, 8, 30, 30)) //left side of alertview
imageView.image = UIImage(named: "error") //add this if you like to show error icon on alertview
let alertController = UIAlertController(title: "Alert!", message: "\nPlease Check Your Internet Availability", preferredStyle: UIAlertControllerStyle.Alert)
alertController.addAction(UIAlertAction(title: "Okay", style: UIAlertActionStyle.Default,handler: nil))
alertController.view.addSubview(imageView) //Add this if you like to user image on alerview
self.presentViewController(alertController, animated: true, completion: nil)
:
func networkStatusChanged(notification: NSNotification) {
if let info = notification.userInfo as? [String:String] {
let status = info["Status"]!
if !status.containsString("Online") {
let imageView = UIImageView(frame: CGRectMake(70, 8, 30, 30)) //left side of alertview
imageView.image = UIImage(named: "error") //add this if you like to show error icon on alertview
let alertController = UIAlertController(title: "Alert!", message: "\nPlease Check Your Internet Availability", preferredStyle: UIAlertControllerStyle.Alert)
alertController.addAction(UIAlertAction(title: "Okay", style: UIAlertActionStyle.Default,handler: nil))
alertController.view.addSubview(imageView) //Add this if you like to user image on alerview
self.presentViewController(alertController, animated: true, completion: nil)
}
else
{
print("Available")
}
}
}
親愛なる接続は、私はすべての画面だけではなく、一度アラートビューのためのコードを記述する必要が警告を表示失ったら、私の質問は –