2017-09-20 14 views
0

내 앱에서 재 시도 버튼을 클릭 할 때마다 앱이 나 빠지고 AppDelegate로 돌아갑니다."Thread 1 : signal SIGABRT"내 프로그램에서 오류가 발생했습니다.

전체 코드 (그것은 많이있어 내가 아는)

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. 
} 


} 

나는 내가 재시도 버튼 뭔가를 클릭하면 잘못 다시 전송되고 있음을 말해 생각하지만 난 정확히 모르겠어요 잘못 전송되었습니다. 누구든지 내가 잘못한 것을 말할 수 있다면, 그것은 중대하게 평가 될 것입니다. 고맙습니다.

+1

재시도 기능이 포함 된 전체 파일을 공유하십시오. –

+0

"[myApp.ViewController Retry :]"어디에서 '다시 시도'가 작성됩니까? ViewController.swift에 없습니까? AppDelegate 코드는 쓸모가 없습니다. 귀하의 질문에서 그것을 제거 할 수 있습니다. – Larme

+0

콘솔 메시지를 삭제해야했습니다. AppDelegate를 불필요하게 사용하는 것을 유감스럽게 생각합니다. –

답변

0

플로린의 답변과 비슷하지만 해결책을 더 빨리 얻을 수있는 방법은 xib 또는 스토리 보드에서 버튼에 연결된 작업을 제거한 경우 (두 가지 중 하나를 사용하는 경우), Retry : 메소드를 다시 당신의 코드. 그래도 도움이되지 않으면 InterfaceBuilder 쪽에서이 버튼에 대한 작업의 스크린 샷을 제공하십시오.

+0

그게 효과가! 고맙습니다, 나는 이미 그렇게했다고 생각하지만 그렇지 않다고 생각합니다. 감사! –

-1

대부분의 경우 재시도 단추의 선택자로 쓰여진 잘못된 기능이있을 수 있습니다. 그것을 확인하고 appcontlegate가 아닌 viewcontroller 파일에서 코드를 게시하십시오.

+0

추가되었지만 콘솔 메시지를 삭제해야했습니다. –