我需要在UIActivityViewController中为所有应用程序显示我的应用程序作为操作扩展(默认) [英] I need to show my App in UIActivityViewController for All Applications as Action Extension(Default)
问题描述
创建了新项目并添加了ActionExtension它工作并在Action Activities中显示但是当我为现有应用程序创建时,Action Extension不显示在设备中(包含swift和Objective-c文件的旧应用程序)
我需要在UiactivityController的Action Extension中显示我的应用程序,但我无法在设备中显示每个应用程序参考图像
***查询:在模拟器(照片应用程序)中显示它并且它在模拟器中的其他应用程序中不显示但是当我在设备中运行时它不会在照片应用程序和其他应用程序中显示
覆盖func viewDidLoad(){
super.viewDidLoad()
//从扩展上下文中获取我们正在处理的项目。
//例如,查找图像并将其放入图像视图中。
//将此替换为适合您的扩展程序支持的类型[s]的内容。
var imageFound = false
for item:self.extensionContext中的AnyObject!.inputItems {
让inputItem = item为! NSExtensionItem
for provider:inputItem.attachments中的AnyObject! {
让itemProvider =提供者为! NSItemProvider
if itemProvider.hasItemConformingToTypeIdentifier(kUTTypeImage as String){
//这是一张图片。我们将加载它,然后将其放在我们的图像视图中。
weak var weakImageView = self.imageView
itemProvider.loadItemForTypeIdentifier(kUTTypeImage as String,options:nil,completionHandler:{(image,error)in
NSOperationQueue.mainQueue()。addOperationWithBlock {
如果让strongImageView = weakImageView {
如果让imageURL = image为?NSURL {
strongImageView.image = UIImage(数据:NSData(contentsOfURL:imageURL) )!)
} else {
strongImageView.image = image as?UIImage
}
}
}
} )
imageFound = true
break
}
}
if(imageFound){
//我们只处理一个图片,所以停止寻找更多。
中断
}
}
}
覆盖func didReceiveMemoryWarning(){
super.didReceiveMemoryWarning()
// Dispose可以重新创建的任何资源。
}
@IBAction func done(){
//将任何已编辑的内容返回给主机应用程序。
//这个模板没有做任何事情,所以我们只是回显传入的项目。
self.extensionContext!.completeRequestReturningItems(self.extensionContext!.inputItems,completionHandler:nil)
}
参考Apple文档和其他链接
**我无法展示我的UiactivityViewController中的应用程序请帮助
嘿我只回答我自己的问题。现在我可以在UIActivityViewController中显示我的AppExtension
我再次使用了我的旧项目并添加了Target - > Action Extension Newly
Xcode->文件 - >创建新目标 - >选择动作扩展 - >完成
要做的事情:
在Plist中添加如Png所示
参考链接
http://code.tutsplus.com/tutorials/ios -8-how-to-build-a-simple-action-extension - cms-22794
http://www.appcoda.com/tag/app-extension/
Created New Project and Added ActionExtension it worked and shows in Action Activities But Action Extension doesn't show in Device when i created for Existing App(Old App which contains swift and Objective-c Files) I need to show my App in Action Extension of UiactivityController but i am unable to show For Every Application in Device refer image
***Query : While in Simulator(Photos App) it shows and it Doesn't shows in Other Apps in Simulator but when i run in Device it Doesn't shows in both Photos App and others
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)
}
Referred Apple Documentation and other links
http://code.tutsplus.com/tutorials/ios-8-how-to-build-a-simple-action-extension--cms-22794
on Extensions didn't find any relevant answer and my Action Extension Plist File (refer image)
**I am unable to show my app in UiactivityViewController Please Help
Hey I am answering to my own question only . Now I am able to show my AppExtension in UIActivityViewController
I took my Old Project again and added Target -> Action Extension Newly
Xcode-> File -> create New Target -> select Action Extension -> Done
Things to do :
In Plist Added like shown in 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>
Result:
Refer links
http://code.tutsplus.com/tutorials/ios-8-how-to-build-a-simple-action-extension--cms-22794
http://www.appcoda.com/tag/app-extension/
这篇关于我需要在UIActivityViewController中为所有应用程序显示我的应用程序作为操作扩展(默认)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!