swift - How to detect taps on image(s) attached in an attributedString and get image(s)' position in it? -
in app, images added attributedstring, , need detect images' position , when images tapped, images stored in core data, once image "deleted" in attributedstring (actually in textview), current deleted image deleted core data.
how can make tags each image when image picked?
the code now:
func imagepickercontroller(picker: uiimagepickercontroller, didfinishpickingimage image: uiimage, editinginfo: [string : anyobject]?) { oksavebtn.enabled = true imagearray.append(image) let thestring = nsmutableattributedstring(attributedstring: textview.attributedtext) let imageattachment = nstextattachment() let newimage = image.resizeimage(image, newwidth: 150) imageattachment.image = newimage let imagestring = nsattributedstring(attachment: imageattachment) thestring.appendattributedstring(imagestring) // trying figure out relationship between entered string , picked images let txt = (thestring.string nsstring).rangeofstring(textview.text) print("txt length : \(txt.length)") print("txt location : \(txt.location)") textview.attributedtext = thestring // ================================================================ self.dismissviewcontrolleranimated(true, completion: nil) /* remark self.dismissviewcontrolleranimated(true) { self.hintlabel.hidden = false uiview.animatewithduration(1.0, delay: 0, options: uiviewanimationoptions.curveeaseout, animations: { self.hintlabel.alpha = 1.0 }, completion: { (finished: bool) -> void in // fade out uiview.animatewithduration(1.0, delay: 0, options: uiviewanimationoptions.curveeasein, animations: { self.hintlabel.alpha = 0 }, completion: { (finished: bool) in self.hintlabel.hidden = true }) }) } */ }
Comments
Post a Comment