Подтвердить что ты не робот

Swift - выполнить Segue

if (view.annotation.title as String!) == "Helgoland " {
  currentLong = 7.889021
  currentLat = 54.180210 
  url = "google.com"

  let alertController: UIAlertController = UIAlertController(title: "Change Map Type", message: nil, preferredStyle: UIAlertControllerStyle.Alert)
  let cancelAction: UIAlertAction = UIAlertAction(title: "Back", style: UIAlertActionStyle.Cancel, handler: nil)
  let button1action: UIAlertAction = UIAlertAction(title: "Product Page", style: UIAlertActionStyle.Default, handler: { (action: UIAlertAction!) -> () in
    performSegueWithIdentifier("showShop", sender: self)
  })
  let button2action: UIAlertAction = UIAlertAction(title: "Video", style: UIAlertActionStyle.Default, handler: { (action: UIAlertAction!) -> () in
    youtubeVideoID = "XX"
    UIApplication.sharedApplication().openURL(NSURL(string: "http://www.youtube.com/watch?v=\(youtubeVideoID)"))
  })
  alertController.addAction(cancelAction)
  alertController.addAction(button1action)
  alertController.addAction(button2action)
  self.presentViewController(alertController, animated: true, completion: nil)
}

Я всегда получаю сообщение об ошибке с

"Неявное использование" я "в закрытии, использование" я ". сделать захват  семантический явный"

но если я устанавливаю self.view, он также терпит неудачу.

4b9b3361

Ответ 1

Вам нужно будет явно использовать self:

self.performSegueWithIdentifier("showShop", sender: self)

И для Swift 3 (спасибо @KingChintz):

self.performSegue(withIdentifier: "showShop", sender: self)

Ответ 2

Для Swift 3

 _ =  self.navigationController?.popToRootViewController(animated: false)