2014-09-25 10 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) 
} 

मैं हमेशास्विफ्ट प्रदर्शन Segue

"बंद में 'स्वयं' की अंतर्निहित उपयोग के साथ कोई त्रुटि मिलती है का उपयोग कब्जा अर्थ स्पष्ट "

लेकिन अगर मैं self.view निर्धारित करते हैं, यह भी विफल रहता है बनाने के लिए।

+0

शायद यह समस्या का कारण बनने वाली एक और संग्रहीत संपत्ति है । वर्तमान लांग, वर्तमान लेट और यूआरएल कहां से परिभाषित हैं? स्विफ्ट 3 में –

उत्तर

63

आप स्पष्ट रूप से स्वयं का उपयोग करना होगा:

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

और स्विफ्ट 3 के लिए (THX @KingChintz):

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

+2

, समतुल्य होगा: '' self.performSegue (withIdentifier: "theID", प्रेषक: स्वयं) '' ' – KingChintz

0

स्विफ्ट 3 के लिए

_ = self.navigationController?.popToRootViewController(animated: false) 
संबंधित मुद्दे