ios – 警告:UIAlertController已经呈现

前端之家收集整理的这篇文章主要介绍了ios – 警告:UIAlertController已经呈现前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我是 swift和XCode的新手所以请原谅我可能非常混乱的代码
运行我的代码时,我收到以下警告:
警告:尝试出示已经出现的内容

我已经检查了论坛并发现了一个关于该问题的帖子….我应用了建议的帮助,如:

if presentedViewController !== nil {
     self.presentViewController(alertController,animated: true,completion: nil)
} else{
     self.dismissViewControllerAnimated(false,completion: nil)
     self.presentViewController(alertController,completion: nil)
}

但是,它仍然给了我同样的警告….所以我想我一定做错了.如果有人可以帮助我,那将是很棒的:)如果有任何关于我如何“清理”我的代码的建议,我感激不尽:)

import UIKit

class ViewController: UIViewController {

@IBOutlet var Label: UILabel!

@IBOutlet var ukFlag: UITextView!

@IBOutlet var movie: UITextView!

@IBOutlet var piano: UITextView!

@IBOutlet var book: UITextView!

@IBOutlet var dance: UITextView!

@IBOutlet var paint: UITextView!

@IBOutlet var row: UITextView!

@IBOutlet var envelope: UITextView!

@IBOutlet var dragon: UITextView!

@IBOutlet var instagram: UITextView!


func londonPuzzle(sender: UIPanGestureRecognizer) {
    let translation = sender.translationInView(self.view)
    sender.view!.center = CGPoint(x: sender.view!.center.x + translation.x,y: sender.view!.center.y + translation.y)
    sender.setTranslation(CGPointZero,inView: self.view)
      self.ifCollided()


}


func misleadOne(sender: UIPanGestureRecognizer) {

    let translation = sender.translationInView(self.view)
    sender.view!.center = CGPoint(x: sender.view!.center.x + translation.x,inView: self.view)
    self.ifCollided()

}

func bestival(sender: UIPanGestureRecognizer) {
    let translation = sender.translationInView(self.view)
    sender.view!.center = CGPoint(x: sender.view!.center.x + translation.x,inView: self.view)
      self.ifCollided()

    }

func rosieProject(sender: UIPanGestureRecognizer) {
    let translation = sender.translationInView(self.view)
    sender.view!.center = CGPoint(x: sender.view!.center.x + translation.x,inView: self.view)
    self.ifCollided()

}

func misleadTwo(sender: UIPanGestureRecognizer) {
    let translation = sender.translationInView(self.view)
    sender.view!.center = CGPoint(x: sender.view!.center.x + translation.x,inView: self.view)
    self.ifCollided()

}

func misleadThree(sender: UIPanGestureRecognizer) {
    let translation = sender.translationInView(self.view)
    sender.view!.center = CGPoint(x: sender.view!.center.x + translation.x,inView: self.view)
    self.ifCollided()

}

func misleadFour(sender: UIPanGestureRecognizer) {
    let translation = sender.translationInView(self.view)
    sender.view!.center = CGPoint(x: sender.view!.center.x + translation.x,inView: self.view)
    self.ifCollided()

}
func voucher(sender: UIPanGestureRecognizer) {
    let translation = sender.translationInView(self.view)
    sender.view!.center = CGPoint(x: sender.view!.center.x + translation.x,inView: self.view)
    self.ifCollided()

}

func welsh(sender: UIPanGestureRecognizer) {
    let translation = sender.translationInView(self.view)
    sender.view!.center = CGPoint(x: sender.view!.center.x + translation.x,inView: self.view)
    self.ifCollided()

}

func hulk(sender: UIPanGestureRecognizer) {
    let translation = sender.translationInView(self.view)
    sender.view!.center = CGPoint(x: sender.view!.center.x + translation.x,inView: self.view)
    self.ifCollided()

}

func ShowAlertWrong(){

    let alertController = UIAlertController(title: "Sorry",message:   " Guess again!",preferredStyle: .Alert)

    let okAction = UIAlertAction( title: "Ok",style:   UIAlertActionStyle.Default) {
        UIAlertAction in

        self.ukFlag.center = CGPointMake(150,225)
        self.movie.center = CGPointMake(150,225)
        self.piano.center = CGPointMake(150,225)
        self.dance.center = CGPointMake(150,225)
        self.paint.center = CGPointMake(150,225)
        self.row.center = CGPointMake(150,225)
        self.envelope.center = CGPointMake(150,225)
        self.dragon.center = CGPointMake(150,225)
        self.instagram.center = CGPointMake(150,225)
    }

    let resetAction = UIAlertAction( title: "Reset",style: UIAlertActionStyle.Default) {
        UIALertAction in

        self.ukFlag.center = CGPointMake(150,225)

    }

    alertController.addAction(okAction)
    alertController.addAction(resetAction)
    self.presentViewController(alertController,completion: nil)

}




func ShowAlertWin(){



    let alertController = UIAlertController(title: "Congrats 原文链接:https://www.f2er.com/iOS/331216.html

猜你在找的iOS相关文章