2016-08-26 11 views

答えて

0

下記の方法で試してみてください。 xcode 8.2、swift 3.0でうまく動作しました

func openURL(_ url: URL) { 
    return 
} 

func openApp(_ urlstring:String) { 

    var responder: UIResponder? = self as UIResponder 
    let selector = #selector(openURL(_:)) 
    while responder != nil { 
     if responder!.responds(to: selector) && responder != self { 
      responder!.perform(selector, with: URL(string: urlstring)!) 
      return 
     } 
     responder = responder?.next 
    } 
} 

// Usage 
//call the method like below 
// self.openApp(urlString) 

// URL string need to included custom scheme. 
// for example, if you created scheme name = customApp 
// urlString will be "customApp://?[name]=[value]" 
// self.openApp("customApp://?category=1") 
関連する問題