Closed perryao closed 9 years ago
Hi,
there should be a way: You should subclass from PARPoiLabel
, not from PARPoi
and to apply your custom UI you might copy the nib file DefaultPoiLabel.xib
into your project and add elements there.
Hi, Thanks for the tip. Unfortunately, I think this is something I need to be able to set in code, as the FLAnimatedImage library uses FLAnimatedImage objects for gifs and this class does not subclass UIImage. If I pass in my gif like so:
var gif = PARPoiLabel(title: "Gif building", theDescription: "A Gif", theImage: UIImage(named: "building.gif"), fromTemplateXib: "PoiLabelWithImage", atLocation: CLLocation(latitude:23.56, longitude: -82.34));
then the image is rendered statically without animating.
Ok I figured it out. Instead of adding the subview in the subclassed PARPoiLabel, I added the subview in the view controller after instantiating the PARPoiLabel. Here's the code:
func createARObjects() {
PARController.sharedARController().clearObjects()
var gif = PARPoiLabel(title: "", theDescription: "", theImage: nil, fromTemplateXib: "PoiLabelWithImage", atLocation: CLLocation(latitude:23.56, longitude:-82.34));
var string = NSBundle.mainBundle().pathForResource("building", ofType: "gif")
var data = NSData(contentsOfFile: string!)
var animatedImage = FLAnimatedImage(animatedGIFData:data)
var animatedImageView = FLAnimatedImageView()
animatedImageView.animatedImage = animatedImage
animatedImageView.frame = gif.labelView.frame
gif.labelView.addSubview(animatedImageView)
gif.offset = CGPointMake(0, 0)
PARController.sharedARController().addObject(gif)
}
So I think it's safe to close this. Thanks for the help!
I'm trying to add a custom view to a PARPoi. Specifically, I'd like to add an FLAnimatedImageView from Flipboards FLAnimatedImage library. I've subclassed PARPoi and overrode renderInView, but this seems to just fill the entire screen with the image with no regard to the given coordinates. How can I add a subview to a PARPoi and ensure that the subview tracks the movement of the device? Thanks! Below is my subclassed PARPoi.