以下URL在iOS 8.3及更低版本上打开,但它不起作用且iOS 9
let instagramURL = NSURL(string: "instagram://app")
Run Code Online (Sandbox Code Playgroud)
为什么网址不会打开?
我已经完成了以下代码在Instagram上发布图像和文本
let fileURL = NSURL(fileURLWithPath: writePath)
self.documentController = UIDocumentInteractionController(URL: fileURL)
self.documentController.delegate = self
self.documentController.UTI = "com.instagram.exclusivegram"//"com.instagram.photo"
self.documentController.annotation = NSDictionary(object: strTitle as String, forKey: "InstagramCaption")
self.documentController.presentOpenInMenuFromRect(self.view.frame, inView: self.view, animated: true)
Run Code Online (Sandbox Code Playgroud)
它在iOS 8.3中运行良好,但iOS 9中缺少Caption.为什么这样,我该如何解决?
我为这样的AVPlayer添加了一个观察者
self.audioPlayer.addObserver(self, forKeyPath: "currentItem.status", options: [NSKeyValueObservingOptions.New, NSKeyValueObservingOptions.Initial], context: nil)
Run Code Online (Sandbox Code Playgroud)
并呼吁
func observeValueForKeyPath(keyPath : NSString, object : AnyObject, change : NSDictionary, context : Void) {
if object as! AVPlayer == self.audioPlayer && keyPath.isEqualToString("currentItem.status")
{
let playerStatus = self.audioPlayer.currentItem!.status.rawValue as Int
if playerStatus == AVPlayerStatus.Failed.rawValue
{
self.replaceCurrentItem(self.fileName)
}
else if playerStatus == AVPlayerStatus.ReadyToPlay.rawValue
{
self.playAudio()
self.updateDurationPeriodcally()
self.updateInfo()
}
else if playerStatus == AVPlayerStatus.Unknown.rawValue
{
print("\(self.audioPlayer.currentItem!.error)")
}
}
}
Run Code Online (Sandbox Code Playgroud)
问题是observeValueForKeyPath
永远不会被称为.
整个代码
func loadPlayer (urlString : NSString)
{
let url : NSURL …
Run Code Online (Sandbox Code Playgroud)