Getting iOS Action Extension template to work -
i trying out action extensions on ios. created new project , loaded action extension template. looking @ template code, seems if select image load actionviewcontroller's imageview. ran action extension , got loaded in share dialogue expected, when selected image did not show in imageview of actionviewcontroller. familiar action extensions let me know missing.
reza
if working on swift project ,in **actionviewcontroller u need retrieve image url
u need add code this
if let strongimageview = weakimageview { if let imageurl = image as? nsurl{ strongimageview.image = uiimage(data: nsdata(contentsofurl: imageurl)!) }else{ strongimageview.image = image as? uiimage } }
for clarification added full code below (actionviewcontroller) ,please go through code ,
override func viewdidload() { super.viewdidload() // item[s] we're handling extension context. // example, image , place image view. // replace appropriate type[s] extension supports. var imagefound = false item: anyobject in self.extensioncontext!.inputitems { let inputitem = item as! nsextensionitem provider: anyobject in inputitem.attachments! { let itemprovider = provider as! nsitemprovider if itemprovider.hasitemconformingtotypeidentifier(kuttypeimage string) { // image. we'll load it, place in our image view. weak var weakimageview = self.imageview itemprovider.loaditemfortypeidentifier(kuttypeimage 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) { // handle 1 image, stop looking more. break } } }
Comments
Post a Comment