"线程1:信号SIGABRT"我的程序出错了

时间:2017-09-20 16:15:18

标签: ios swift unrecognized-selector

每当我点击我的应用程序上的重试按钮时,它会将我从应用程序中抛出并返回到AppDelegate。

整个代码(我知道很多)

import UIKit

class ViewController: UIViewController {

@IBOutlet weak var logo: UIImageView!

@IBOutlet weak var gameOver: UIImageView!

@IBAction func Play(_ sender: Any) { //What Happens After you click the "Play" button

    tapsValid = true
    ballChange = true
    self.gameOver.isHidden = true
    self.retry.isHidden = true
    self.Ball.isHidden = false
    self.logo.isHidden = true
    self.Play.isHidden = true
    self.scoreBoard.isHidden = true
    scoreOnBoard.isHidden = true
    highScoreOnBoard.isHidden = true
    scoreLabel.isHidden = false

    self.Ball.center.x = 178.0
    self.Ball.center.y = 390.0
    self.pillar.center = CGPoint(x: 175.0,y: 436.0)
    self.pillar2.center = CGPoint(x: 214.0,y: 407.0)
    self.pillarTop2.center = CGPoint(x: pillar.center.x, y: pillar.center.y-35)
    self.pillarTop3.center = CGPoint(x: pillar2.center.x, y: pillar2.center.y-35)

    timer = Timer.scheduledTimer(timeInterval: 0.045, target: self, selector: #selector(ViewController.movement), userInfo: nil, repeats: true)

    self.pillar3.center = pillarPlacement(x: pillar2.center.x, y: pillar2.center.y)
    self.pillar4.center = pillarPlacement(x: pillar3.center.x, y: pillar3.center.y)
    self.pillar5.center = pillarPlacement(x: pillar4.center.x, y: pillar4.center.y)
    self.pillar6.center = pillarPlacement(x: pillar5.center.x, y: pillar5.center.y)
    self.pillar7.center = pillarPlacement(x: pillar6.center.x, y: pillar6.center.y)
    self.pillar8.center = pillarPlacement(x: pillar7.center.x, y: pillar7.center.y)
    self.pillar9.center = pillarPlacement(x: pillar8.center.x, y: pillar8.center.y)
    self.pillar10.center = pillarPlacement(x: pillar9.center.x, y: pillar9.center.y)
    self.pillar11.center = pillarPlacement(x: pillar10.center.x, y: pillar10.center.y)
    self.pillar12.center = pillarPlacement(x: pillar11.center.x, y: pillar11.center.y)
    self.pillar13.center = pillarPlacement(x: pillar12.center.x, y: pillar12.center.y)
    self.pillar14.center = pillarPlacement(x: pillar13.center.x, y: pillar13.center.y)
    self.pillar15.center = pillarPlacement(x: pillar14.center.x, y: pillar14.center.y)
    self.pillar16.center = pillarPlacement(x: pillar15.center.x, y: pillar15.center.y)
    self.pillar17.center = pillarPlacement(x: pillar16.center.x, y: pillar16.center.y)
    self.pillar18.center = pillarPlacement(x: pillar17.center.x, y: pillar17.center.y)
    self.pillar19.center = pillarPlacement(x: pillar18.center.x, y: pillar18.center.y)
    self.pillar20.center = pillarPlacement(x: pillar19.center.x, y: pillar19.center.y)
    self.pillar21.center = pillarPlacement(x: pillar20.center.x, y: pillar20.center.y)
    self.pillar22.center = pillarPlacement(x: pillar21.center.x, y: pillar21.center.y)
    self.pillar23.center = pillarPlacement(x: pillar22.center.x, y: pillar22.center.y)
    self.pillar24.center = pillarPlacement(x: pillar23.center.x, y: pillar23.center.y)
    self.pillar25.center = pillarPlacement(x: pillar24.center.x, y: pillar24.center.y)
    self.pillar26.center = pillarPlacement(x: pillar25.center.x, y: pillar25.center.y)

    self.pillar.isHidden = false
    self.pillar2.isHidden = false
    self.pillar3.isHidden = false
    self.pillar4.isHidden = false
    self.pillar5.isHidden = false
    self.pillar6.isHidden = false
    self.pillar7.isHidden = false
    self.pillar8.isHidden = false
    self.pillar9.isHidden = false
    self.pillar10.isHidden = false
    self.pillar11.isHidden = false
    self.pillar12.isHidden = false
    self.pillar13.isHidden = false
    self.pillar14.isHidden = false
    self.pillar15.isHidden = false
    self.pillar16.isHidden = false
    self.pillar17.isHidden = false
    self.pillar18.isHidden = false
    self.pillar19.isHidden = false
    self.pillar20.isHidden = false
    self.pillar21.isHidden = false
    self.pillar22.isHidden = false
    self.pillar23.isHidden = false
    self.pillar24.isHidden = false
    self.pillar25.isHidden = false
    self.pillar26.isHidden = false
    self.pillarTop.isHidden = false
    self.pillarTop2.isHidden = false
    self.pillarTop3.isHidden = false
}
@IBAction func Retry(sender: Any) {
    self.viewDidLoad()
    self.Play(Play)
}

@IBOutlet var gameView: UIView!

@IBOutlet weak var pillar26: UIImageView!
@IBOutlet weak var pillar25: UIImageView!
@IBOutlet weak var pillar24: UIImageView!
@IBOutlet weak var pillar23: UIImageView!
@IBOutlet weak var pillar22: UIImageView!
@IBOutlet weak var pillar21: UIImageView!
@IBOutlet weak var pillar20: UIImageView!
@IBOutlet weak var pillar19: UIImageView!
@IBOutlet weak var pillar18: UIImageView!
@IBOutlet weak var pillar17: UIImageView!
@IBOutlet weak var pillar16: UIImageView!
@IBOutlet weak var pillar15: UIImageView!
@IBOutlet weak var pillar14: UIImageView!
@IBOutlet weak var pillar13: UIImageView!
@IBOutlet weak var pillar12: UIImageView!
@IBOutlet weak var pillar11: UIImageView!
@IBOutlet weak var pillar10: UIImageView!
@IBOutlet weak var pillar9: UIImageView!
@IBOutlet weak var pillar8: UIImageView!
@IBOutlet weak var pillar7: UIImageView!
@IBOutlet weak var pillar6: UIImageView!
@IBOutlet weak var pillar5: UIImageView!
@IBOutlet weak var pillar4: UIImageView!
@IBOutlet weak var pillar3: UIImageView!
@IBOutlet weak var pillar2: UIImageView!
@IBOutlet weak var pillar: UIImageView!
@IBOutlet weak var pillarTop6: UIImageView!
@IBOutlet weak var pillarTop5: UIImageView!
@IBOutlet weak var pillarTop4: UIImageView!
@IBOutlet weak var pillarTop3: UIImageView!
@IBOutlet weak var pillarTop2: UIImageView!
@IBOutlet weak var pillarTop: UIImageView!
@IBOutlet weak var Play: UIButton!
@IBOutlet weak var highScoreOnBoard: UILabel!
@IBOutlet weak var scoreOnBoard: UILabel!
@IBOutlet weak var scoreLabel: UILabel!
var timer = Timer()
var tapsValid:Bool?
var ballRight:Bool?
var ballChange:Bool?
var ballCenter: CGPoint?
var pillarCenter: CGPoint?
var pillar2Center: CGPoint?
var pillar3Center: CGPoint?
var pillar4Center: CGPoint?
var pillar5Center: CGPoint?
var pillar6Center: CGPoint?
var pillar7Center: CGPoint?
var pillar8Center: CGPoint?
var pillar9Center: CGPoint?
var pillar10Center: CGPoint?
var pillar11Center: CGPoint?
var pillar12Center: CGPoint?
var pillar13Center: CGPoint?
var pillar14Center: CGPoint?
var pillar15Center: CGPoint?
var pillar16Center: CGPoint?
var pillar17Center: CGPoint?
var pillar18Center: CGPoint?
var pillar19Center: CGPoint?
var pillar20Center: CGPoint?
var pillar21Center: CGPoint?
var pillar22Center: CGPoint?
var pillar23Center: CGPoint?
var pillar24Center: CGPoint?
var pillar25Center: CGPoint?
var pillar26Center: CGPoint?
var pillarTopCenter: CGPoint?
var pillarTop2Center: CGPoint?
var pillarTop3Center: CGPoint?
var pillarTop4Center: CGPoint?
var pillarTop5Center: CGPoint?
var pillarTop6Center: CGPoint?



@IBOutlet weak var scoreBoard: UIImageView!
@IBOutlet weak var retry: UIButton!
@IBOutlet weak var Ball: UIImageView!
//Start Screen
override func viewDidLoad() {
    super.viewDidLoad()

    self.gameOver.isHidden = true
    self.retry.isHidden = true
    self.Ball.isHidden = true
    self.logo.isHidden = false
    self.Play.isHidden = false
    self.scoreBoard.isHidden = true
    self.Ball.isHidden = true
    self.pillar.isHidden = true
    self.pillar2.isHidden = true
    self.pillar3.isHidden = true
    self.pillar4.isHidden = true
    self.pillar5.isHidden = true
    self.pillar6.isHidden = true
    self.pillar7.isHidden = true
    self.pillar8.isHidden = true
    self.pillar9.isHidden = true
    self.pillar10.isHidden = true
    self.pillar11.isHidden = true
    self.pillar12.isHidden = true
    self.pillar13.isHidden = true
    self.pillar14.isHidden = true
    self.pillar15.isHidden = true
    self.pillar16.isHidden = true
    self.pillar17.isHidden = true
    self.pillar18.isHidden = true
    self.pillar19.isHidden = true
    self.pillar20.isHidden = true
    self.pillar21.isHidden = true
    self.pillar22.isHidden = true
    self.pillar23.isHidden = true
    self.pillar24.isHidden = true
    self.pillar25.isHidden = true
    self.pillar26.isHidden = true
    self.pillarTop.isHidden = true
    self.pillarTop2.isHidden = true
    self.pillarTop3.isHidden = true
    self.pillarTop4.isHidden = true
    self.pillarTop5.isHidden = true
    self.pillarTop6.isHidden = true
}

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
    if tapsValid == true
    {
        if ballRight == true
        {
            ballChange = false
        } else
        {
            ballChange = true
        }
    }
}

func movement()
{
    ballCenter = self.Ball.center
    pillarCenter = self.pillar.center
    pillar2Center = self.pillar2.center
    pillar3Center = self.pillar3.center
    pillar4Center = self.pillar4.center
    pillar5Center = self.pillar5.center
    pillar6Center = self.pillar6.center
    pillar7Center = self.pillar7.center
    pillar8Center = self.pillar8.center
    pillar9Center = self.pillar9.center
    pillar10Center = self.pillar10.center
    pillar11Center = self.pillar11.center
    pillar12Center = self.pillar12.center
    pillar13Center = self.pillar13.center
    pillar14Center = self.pillar14.center
    pillar15Center = self.pillar15.center
    pillar16Center = self.pillar16.center
    pillar17Center = self.pillar17.center
    pillar18Center = self.pillar18.center
    pillar19Center = self.pillar19.center
    pillar20Center = self.pillar20.center
    pillar21Center = self.pillar21.center
    pillar22Center = self.pillar22.center
    pillar23Center = self.pillar23.center
    pillar24Center = self.pillar24.center
    pillar25Center = self.pillar25.center
    pillar26Center = self.pillar26.center
    pillarTopCenter = self.pillarTop.center
    pillarTop2Center = self.pillarTop2.center
    pillarTop3Center = self.pillarTop3.center
    pillarTop4Center = self.pillarTop4.center
    pillarTop5Center = self.pillarTop5.center
    pillarTop6Center = self.pillarTop6.center


    if ballChange == false
    {
        ballRight = false
    } else
    {
        ballRight = true
    }
    if ballRight == true
    {
        Ball.center.x += 6.5
        Ball.center.y -= 0.5
    }else
    {
        Ball.center.x -= 6.5
        Ball.center.y -= 0.5
    }

    Ball.center.y += 0.5
    pillar.center.y += 5.0
    pillar2.center.y += 5.0
    pillar3.center.y += 5.0
    pillar4.center.y += 5.0
    pillar5.center.y += 5.0
    pillar6.center.y += 5.0
    pillar7.center.y += 5.0
    pillar8.center.y += 5.0
    pillar9.center.y += 5.0
    pillar10.center.y += 5.0
    pillar11.center.y += 5.0
    pillar12.center.y += 5.0
    pillar13.center.y += 5.0
    pillar14.center.y += 5.0
    pillar15.center.y += 5.0
    pillar16.center.y += 5.0
    pillar17.center.y += 5.0
    pillar18.center.y += 5.0
    pillar19.center.y += 5.0
    pillar20.center.y += 5.0
    pillar21.center.y += 5.0
    pillar22.center.y += 5.0
    pillar23.center.y += 5.0
    pillar24.center.y += 5.0
    pillar25.center.y += 5.0
    pillar26.center.y += 5.0

    pillar.center = movePillarUp(floatx: pillar.center.x, floaty: pillar.center.y, pillarNumber: 1)
    pillar2.center = movePillarUp(floatx: pillar2.center.x, floaty: pillar2.center.y, pillarNumber: 2)
    pillar3.center = movePillarUp(floatx: pillar3.center.x, floaty: pillar3.center.y, pillarNumber: 3)
    pillar4.center = movePillarUp(floatx: pillar4.center.x, floaty: pillar4.center.y, pillarNumber: 4)
    pillar5.center = movePillarUp(floatx: pillar5.center.x, floaty: pillar5.center.y, pillarNumber: 5)
    pillar6.center = movePillarUp(floatx: pillar6.center.x, floaty: pillar6.center.y, pillarNumber: 6)
    pillar7.center = movePillarUp(floatx: pillar7.center.x, floaty: pillar7.center.y, pillarNumber: 7)
    pillar8.center = movePillarUp(floatx: pillar8.center.x, floaty: pillar8.center.y, pillarNumber: 8)
    pillar9.center = movePillarUp(floatx: pillar9.center.x, floaty: pillar9.center.y, pillarNumber: 9)
    pillar10.center = movePillarUp(floatx: pillar10.center.x, floaty: pillar10.center.y, pillarNumber: 10)
    pillar11.center = movePillarUp(floatx: pillar11.center.x, floaty: pillar11.center.y, pillarNumber: 11)
    pillar12.center = movePillarUp(floatx: pillar12.center.x, floaty: pillar12.center.y, pillarNumber: 12)
    pillar13.center = movePillarUp(floatx: pillar13.center.x, floaty: pillar13.center.y, pillarNumber: 13)
    pillar14.center = movePillarUp(floatx: pillar14.center.x, floaty: pillar14.center.y, pillarNumber: 14)
    pillar15.center = movePillarUp(floatx: pillar15.center.x, floaty: pillar15.center.y, pillarNumber: 15)
    pillar16.center = movePillarUp(floatx: pillar16.center.x, floaty: pillar16.center.y, pillarNumber: 16)
    pillar17.center = movePillarUp(floatx: pillar17.center.x, floaty: pillar17.center.y, pillarNumber: 17)
    pillar18.center = movePillarUp(floatx: pillar18.center.x, floaty: pillar18.center.y, pillarNumber: 18)
    pillar19.center = movePillarUp(floatx: pillar19.center.x, floaty: pillar19.center.y, pillarNumber: 19)
    pillar20.center = movePillarUp(floatx: pillar20.center.x, floaty: pillar20.center.y, pillarNumber: 20)
    pillar21.center = movePillarUp(floatx: pillar21.center.x, floaty: pillar21.center.y, pillarNumber: 21)
    pillar22.center = movePillarUp(floatx: pillar22.center.x, floaty: pillar22.center.y, pillarNumber: 22)
    pillar23.center = movePillarUp(floatx: pillar23.center.x, floaty: pillar23.center.y, pillarNumber: 23)
    pillar24.center = movePillarUp(floatx: pillar24.center.x, floaty: pillar24.center.y, pillarNumber: 24)
    pillar25.center = movePillarUp(floatx: pillar25.center.x, floaty: pillar25.center.y, pillarNumber: 25)
    pillar26.center = movePillarUp(floatx: pillar26.center.x, floaty: pillar26.center.y, pillarNumber: 26)

    if (((Ball.center.x > pillarTop.center.x - 50) && (Ball.center.x < pillarTop.center.x + 50) && (Ball.center.y > pillarTop.center.y - 45) && (Ball.center.y < pillarTop.center.y + 45)) ||
        ((Ball.center.x > pillarTop.center.x - 50) && (Ball.center.x < pillarTop.center.x + 50) && (Ball.center.y > pillarTop.center.y - 45) && (Ball.center.y < pillarTop.center.y + 45)) ||
        ((Ball.center.x > pillarTop2.center.x - 50) && (Ball.center.x < pillarTop2.center.x + 50) && (Ball.center.y > pillarTop2.center.y - 45) && (Ball.center.y < pillarTop2.center.y + 45)) ||
        ((Ball.center.x > pillarTop3.center.x - 50) && (Ball.center.x < pillarTop3.center.x + 50) && (Ball.center.y > pillarTop3.center.y - 45) && (Ball.center.y < pillarTop3.center.y + 45)) ||
        ((Ball.center.x > pillarTop4.center.x - 50) && (Ball.center.x < pillarTop4.center.x + 50) && (Ball.center.y > pillarTop4.center.y - 45) && (Ball.center.y < pillarTop4.center.y + 45)) ||
        ((Ball.center.x > pillarTop5.center.x - 50) && (Ball.center.x < pillarTop5.center.x + 50) && (Ball.center.y > pillarTop5.center.y - 45) && (Ball.center.y < pillarTop5.center.y + 45)) ||
        ((Ball.center.x > pillarTop6.center.x - 50) && (Ball.center.x < pillarTop6.center.x + 50) && (Ball.center.y > pillarTop6.center.y - 45) && (Ball.center.y < pillarTop6.center.y + 45)))
    {

    }
    else
    {
    gameOverScreen()
    }
}
func movePillarUp(floatx: CGFloat, floaty: CGFloat, pillarNumber: Int) -> (CGPoint)
{

    var center = CGPoint(x: floatx,y: floaty)
    if checkPillarPosition(y: floaty) == true
    {
        switch pillarNumber
        {
        case 1:
            gameView.sendSubview(toBack: pillar)
            center = pillarPlacement(x: self.pillar26.center.x, y: self.pillar26.center.y)
            break
        case 2:
            gameView.sendSubview(toBack: pillar2)
            center = pillarPlacement(x: self.pillar.center.x, y: self.pillar.center.y)
            break
        case 3:
            gameView.sendSubview(toBack: pillar3)
            center = pillarPlacement(x: self.pillar2.center.x, y: self.pillar2.center.y)
            break
        case 4:
            gameView.sendSubview(toBack: pillar4)
            center = pillarPlacement(x: self.pillar3.center.x, y: self.pillar3.center.y)
            break
        case 5:
            gameView.sendSubview(toBack: pillar5)
            center = pillarPlacement(x: self.pillar4.center.x, y: self.pillar4.center.y)
            break
        case 6:
            gameView.sendSubview(toBack: pillar6)
            center = pillarPlacement(x: self.pillar5.center.x, y: self.pillar5.center.y)
            break
        case 7:
            gameView.sendSubview(toBack: pillar7)
            center = pillarPlacement(x: self.pillar6.center.x, y: self.pillar6.center.y)
            break
        case 8:
            gameView.sendSubview(toBack: pillar8)
            center = pillarPlacement(x: self.pillar7.center.x, y: self.pillar7.center.y)
            break
        case 9:
            gameView.sendSubview(toBack: pillar9)
            center = pillarPlacement(x: self.pillar8.center.x, y: self.pillar8.center.y)
            break
        case 10:
            gameView.sendSubview(toBack: pillar10)
            center = pillarPlacement(x: self.pillar9.center.x, y: self.pillar9.center.y)
            break
        case 11:
            gameView.sendSubview(toBack: pillar11)
            center = pillarPlacement(x: self.pillar10.center.x, y: self.pillar10.center.y)
            break
        case 12:
            gameView.sendSubview(toBack: pillar12)
            center = pillarPlacement(x: self.pillar12.center.x, y: self.pillar12.center.y)
            break
        case 13:
            gameView.sendSubview(toBack: pillar13)
            center = pillarPlacement(x: self.pillar12.center.x, y: self.pillar12.center.y)
            break
        case 14:
            gameView.sendSubview(toBack: pillar14)
            center = pillarPlacement(x: self.pillar13.center.x, y: self.pillar13.center.y)
            break
        case 15:
            gameView.sendSubview(toBack: pillar15)
            center = pillarPlacement(x: self.pillar14.center.x, y: self.pillar14.center.y)
            break
        case 16:
            gameView.sendSubview(toBack: pillar16)
            center = pillarPlacement(x: self.pillar15.center.x, y: self.pillar15.center.y)
            break
        case 17:
            gameView.sendSubview(toBack: pillar17)
            center = pillarPlacement(x: self.pillar16.center.x, y: self.pillar16.center.y)
            break
        case 18:
            gameView.sendSubview(toBack: pillar18)
            center = pillarPlacement(x: self.pillar17.center.x, y: self.pillar17.center.y)
            break
        case 19:
            gameView.sendSubview(toBack: pillar19)
            center = pillarPlacement(x: self.pillar18.center.x, y: self.pillar18.center.y)
            break
        case 20:
            gameView.sendSubview(toBack: pillar20)
            center = pillarPlacement(x: self.pillar19.center.x, y: self.pillar19.center.y)
            break
        case 21:
            gameView.sendSubview(toBack: pillar21)
            center = pillarPlacement(x: self.pillar20.center.x, y: self.pillar20.center.y)
            break
        case 22:
            gameView.sendSubview(toBack: pillar22)
            center = pillarPlacement(x: self.pillar21.center.x, y: self.pillar21.center.y)
            break
        case 23:
            gameView.sendSubview(toBack: pillar23)
            center = pillarPlacement(x: self.pillar22.center.x, y: self.pillar22.center.y)
            break
        case 24:
            gameView.sendSubview(toBack: pillar24)
            center = pillarPlacement(x: self.pillar23.center.x, y: self.pillar23.center.y)
            break
        case 25:
            gameView.sendSubview(toBack: pillar25)
            center = pillarPlacement(x: self.pillar24.center.x, y: self.pillar24.center.y)
            break
        case 26:
            gameView.sendSubview(toBack: pillar26)
            center = pillarPlacement(x: self.pillar25.center.x, y: self.pillar25.center.y)
            break
        default:
            break

        }

    }
    return(center)
}

func gameOverScreen()
{
    tapsValid = false
    timer.invalidate()
    scoreLabel.isHidden = true
    gameOver.isHidden = false
    retry.isHidden = false
    scoreBoard.isHidden = false

    scoreOnBoard.isHidden = false
    highScoreOnBoard.isHidden = false

    gameView.sendSubview(toBack: pillar)
    gameView.sendSubview(toBack: pillar2)
    gameView.sendSubview(toBack: pillar3)
    gameView.sendSubview(toBack: pillar4)
    gameView.sendSubview(toBack: pillar5)
    gameView.sendSubview(toBack: pillar6)
    gameView.sendSubview(toBack: pillar7)
    gameView.sendSubview(toBack: pillar8)
    gameView.sendSubview(toBack: pillar9)
    gameView.sendSubview(toBack: pillar10)
    gameView.sendSubview(toBack: pillar11)
    gameView.sendSubview(toBack: pillar12)
    gameView.sendSubview(toBack: pillar13)
    gameView.sendSubview(toBack: pillar14)
    gameView.sendSubview(toBack: pillar15)
    gameView.sendSubview(toBack: pillar16)
    gameView.sendSubview(toBack: pillar17)
    gameView.sendSubview(toBack: pillar18)
    gameView.sendSubview(toBack: pillar19)
    gameView.sendSubview(toBack: pillar20)
    gameView.sendSubview(toBack: pillar21)
    gameView.sendSubview(toBack: pillar22)
    gameView.sendSubview(toBack: pillar23)
    gameView.sendSubview(toBack: pillar24)
    gameView.sendSubview(toBack: pillar25)
    gameView.sendSubview(toBack: pillar26)



}
func checkPillarPosition(y: CGFloat) -> (Bool)
{
    var low = false
    if y>720
    {
        low = true
    }
    return(low)
}

override func viewDidLayoutSubviews()
{
    if let newBallCenter = ballCenter{
        self.Ball.center = newBallCenter
    }
    if let newPillarCenter = pillarCenter{
        self.pillar.center = newPillarCenter
    }
    if let newPillar2Center = pillar2Center{
        self.pillar2.center = newPillar2Center
    }
    if let newPillar3Center = pillar3Center{
        self.pillar3.center = newPillar3Center
    }
    if let newPillar4Center = pillar4Center{
        self.pillar4.center = newPillar4Center
    }
    if let newPillar5Center = pillar5Center{
        self.pillar5.center = newPillar5Center
    }
    if let newPillar6Center = pillar6Center{
        self.pillar6.center = newPillar6Center
    }
    if let newPillar7Center = pillar7Center{
        self.pillar7.center = newPillar7Center
    }
    if let newPillar8Center = pillar8Center{
        self.pillar8.center = newPillar8Center
    }
    if let newPillar9Center = pillar9Center{
        self.pillar9.center = newPillar9Center
    }
    if let newPillar10Center = pillar10Center{
        self.pillar10.center = newPillar10Center
    }
    if let newPillar11Center = pillar11Center{
        self.pillar11.center = newPillar11Center
    }
    if let newPillar12Center = pillar12Center{
        self.pillar12.center = newPillar12Center
    }
    if let newPillar13Center = pillar13Center{
        self.pillar13.center = newPillar13Center
    }
    if let newPillar14Center = pillar14Center{
        self.pillar14.center = newPillar14Center
    }
    if let newPillar15Center = pillar15Center{
        self.pillar15.center = newPillar15Center
    }
    if let newPillar16Center = pillar16Center{
        self.pillar16.center = newPillar16Center
    }
    if let newPillar17Center = pillar17Center{
        self.pillar17.center = newPillar17Center
    }
    if let newPillar18Center = pillar18Center{
        self.pillar18.center = newPillar18Center
    }
    if let newPillar19Center = pillar19Center{
        self.pillar19.center = newPillar19Center
    }
    if let newPillar20Center = pillar20Center{
        self.pillar20.center = newPillar20Center
    }
    if let newPillar21Center = pillar21Center{
        self.pillar21.center = newPillar21Center
    }
    if let newPillar22Center = pillar22Center{
        self.pillar22.center = newPillar22Center
    }
    if let newPillar24Center = pillar24Center{
        self.pillar24.center = newPillar24Center
    }
    if let newPillar25Center = pillar25Center{
        self.pillar25.center = newPillar25Center
    }
    if let newPillar26Center = pillar26Center{
        self.pillar26.center = newPillar26Center
    }
    if let newPillarTopCenter = pillarTopCenter{
        self.pillarTop.center = newPillarTopCenter
    }
    if let newPillarTop2Center = pillarTop2Center{
        self.pillarTop2.center = newPillarTop2Center
    }
    if let newPillarTop3Center = pillarTop3Center{
        self.pillarTop3.center = newPillarTop3Center
    }
    if let newPillarTop4Center = pillarTop4Center{
        self.pillarTop4.center = newPillarTop4Center
    }
    if let newPillarTop5Center = pillarTop5Center{
        self.pillarTop5.center = newPillarTop5Center
    }
    if let newPillarTop6Center = pillarTop6Center{
        self.pillarTop6.center = newPillarTop6Center
    }
}
// This Function Places the Pillars
func pillarPlacement(x:CGFloat , y:CGFloat ) -> (CGPoint)
{
    var pillarNewX:CGFloat
    var pillarNewY:CGFloat

    var random:Int = Int(arc4random() % 2)

    if random == 1
    {
        pillarNewX = x + 39
        pillarNewY = y - 29

        if pillarNewX  >= 319
        {
            pillarNewX = x-40
            pillarNewY = y-30
        }
    }
    else
    {
        pillarNewX = x - 40
        pillarNewY = y - 30

        if pillarNewX  <= 17
        {
            pillarNewX = x+39
            pillarNewY = y-29
        }
    }
    var newPillarCenter = CGPoint(x: pillarNewX,y:  pillarNewY)
    return(newPillarCenter)

}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}


}

我认为它告诉我,当我点击重试按钮时,某些内容被错误地发回,但我不确切地知道发送的内容不正确。如果有人能告诉我我做错了什么,那将是非常感激的。谢谢。

2 个答案:

答案 0 :(得分:0)

与Florin的答案类似,但可能会让您的解决方案更快,如果您删除了xib或故事板中按钮附加的操作(假设您正在使用其中任何一个),那么请重新添加定位您的Retry:方法码。如果这没有帮助,请在InterfaceBuilder端提供此按钮的操作的屏幕截图。

答案 1 :(得分:-1)

您很可能将错误的函数写为重试按钮的选择器。检查它,也发布viewcontroller文件中的代码而不是appdelegate。