2014-09-25 22 views
20
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) 
} 

ottengo sempre un errore conSwift eseguire Segue

"uso implicito del 'sé' in chiusura utilizzare per rendere la cattura semantica esplicita"

ma se ho impostato self.view, fallisce anche.

+0

Forse è un'altra proprietà memorizzata che causa il problema . Dove sono definiti currentLong, currentLat e url ad esempio? –

risposta

63

Sarà necessario utilizzare in modo esplicito di sé:

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

E per Swift 3 (thx @KingChintz):

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

+2

in Swift3, l'equivalente sarà: '' 'self.performSegue (withIdentifier:" theID ", mittente: self)' '' – KingChintz

0

Per Swift 3

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