San*_*nju 7 objective-c ios uiactivityviewcontroller swift swift2
创建了新项目并添加了ActionExtension它工作并在Action Activities中显示但是当我为现有应用程序(包含swift和Objective-c文件的旧应用程序)创建时,Action Extension不显示在Device中我需要在Action Extension中显示我的应用程序UiactivityController但我无法在Device参考图像中显示For Every Application

***查询:在模拟器(照片应用程序)中显示它并且它在模拟器中的其他应用程序中不显示但是当我在设备中运行时它不会在照片应用程序和其他应用程序中显示
override func viewDidLoad() {
super.viewDidLoad()
// Get the item[s] we're handling from the extension context.
// For example, look for an image and place it into an image view.
// Replace this with something appropriate for the type[s] your extension supports.
var imageFound = false
for item: AnyObject in self.extensionContext!.inputItems {
let inputItem = item as! NSExtensionItem
for provider: AnyObject in inputItem.attachments! {
let itemProvider = provider as! NSItemProvider
if itemProvider.hasItemConformingToTypeIdentifier(kUTTypeImage as String) {
// This is an image. We'll load it, then place it in our image view.
weak var weakImageView = self.imageView
itemProvider.loadItemForTypeIdentifier(kUTTypeImage as String, options: nil, completionHandler: { (image, error) in
NSOperationQueue.mainQueue().addOperationWithBlock {
if let strongImageView = weakImageView {
if let imageURL = image as? NSURL{
strongImageView.image = UIImage(data: NSData(contentsOfURL: imageURL)!)
}else{
strongImageView.image = image as? UIImage
}
}
}
})
imageFound = true
break
}
}
if (imageFound) {
// We only handle one image, so stop looking for more.
break
}
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func done() {
// Return any edited content to the host app.
// This template doesn't do anything, so we just echo the passed in items.
self.extensionContext!.completeRequestReturningItems(self.extensionContext!.inputItems, completionHandler: nil)
}
Run Code Online (Sandbox Code Playgroud)
推荐的Apple文档和其他链接
http://code.tutsplus.com/tutorials/ios-8-how-to-build-a-simple-action-extension--cms-22794
在Extensions上找不到任何相关答案和我的Action Extension Plist文件(参见图片)
**我无法在UiactivityViewController中显示我的应用程序请帮助
San*_*nju 11
嘿,我只回答我自己的问题.现在我可以在UIActivityViewController中显示我的AppExtension
我再次拿走了我的旧项目并添加了Target - > Action Extension
Xcode-> File - > create New Target - >选择Action Extension - > Done
在Plist中添加如Png中所示
http://i.stack.imgur.com/KBwdil.png
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>NSExtensionActivationRule</key>
<dict>
<key>NSExtensionActivationSupportsImageWithMaxCount</key>
<integer>1</integer>
</dict>
</dict>
<key>NSExtensionMainStoryboard</key>
<string>MainInterface</string>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.ui-services</string>
</dict>
Run Code Online (Sandbox Code Playgroud)
参考链接
http://code.tutsplus.com/tutorials/ios-8-how-to-build-a-simple-action-extension--cms-22794
http://www.appcoda.com/tag/app-extension/
| 归档时间: |
|
| 查看次数: |
5932 次 |
| 最近记录: |