我需要在iOS下共享/打开一些不同的文件,例如iCloud的图像或iBooks的pdf.文本和图像有几个例子,但在其他方面没什么...
我创造了自己的UIActivityItemProvider; 简化版本:
class MyItemProvider: UIActivityItemProvider {
override func item() -> AnyObject {
self.placeholderItem
}
override func activityViewController(activityViewController: UIActivityViewController, dataTypeIdentifierForActivityType activityType: String?) -> String {
return kUTTypePDF as String
}
func activityViewControllerPlaceholderItem(activityViewController: UIActivityViewController) -> AnyObject {
return self.placeholderItem
}
}
Run Code Online (Sandbox Code Playgroud)
并开始分享如下:
let myPDF = NSData(contentsOfURL: NSBundle.mainBundle().URLForResource("testpdf", withExtension: "pdf")) {
let activityVC = UIActivityViewController(activityItems: [MyItemProvider(placeHolder: myPDF)], applicationActivities: nil)
self.presentViewController(activityVC, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)
我期待一个像以下一样的共享:
但我得到的只是:
有什么建议?
对于通知应用程序,我需要调用先前通过APNS发送的消息,以防这些消息过时或在其他设备上读取 - 即使应用程序未运行.
由于没有"删除"-call via APN并且还没有启动应用程序remote notifications,我认为唯一可行的方法是使用PushKit和Voice over IP后台模式.由于我们不使用VOIP,因此应用可能会被拒绝.
另一个应用程序telegram能够删除在另一台设备上读取的消息 - 即使这个应用程序没有VOIP支持.所以我错过了一些或者telegram只是违反了苹果的指导方针?
问候
coyer
因为UILocalNotification现在已弃用,所以我将代码移至新UNNotificationRequestAPI。
它指出:' cancelLocalNotification ' 在 iOS 10.0 中被弃用:使用 UserNotifications Framework's-[UNUserNotificationCenter removePendingNotificationRequestsWithIdentifiers:]
但它似乎并不相等-虽然我可以随时删除消息cancelLocalNotification(即使它们已显示/已发送),但似乎removePendingNotificationRequestsWithIdentifiers只能删除未发送的通知。这真的很烦人。
所以我的问题是:是否有一种有效的方法可以删除排队的通知,UNNotificationRequest或者我应该忽略那些弃用警告?
基本上我想从其他应用程序(例如dropbox)检索文件(例如pdf)以便稍后存储和修改.
我为该任务编写了一个共享扩展,可以迭代NSExtensionItem并可以找出我的文件 - 但我不知道他们的原始文件名.
我注意到其他应用程序获得了文件名 - 但是在iOS中使用"打开方式"功能调用它们.
那么我如何在我的共享扩展中获取文件名?
提前致谢.
我想将一组CGPoint值传递给另一个Objective-C函数.
迅速:
var myPoints:[CGPoints]? = [CGPoint(x: 0, y:0)]
ObjCWrapper.callSomething(&myPoints)
Run Code Online (Sandbox Code Playgroud)
Objective-C的
+ (void) callSomething: (CGPoint []) points {...}
Run Code Online (Sandbox Code Playgroud)
我得到的错误:
Cannot invoke 'callSomething' with an argument list of type 'inout [CGPoint]?)'
Run Code Online (Sandbox Code Playgroud)