I am having an issue setting up a UITapGestureRecognizer
calling a shared class across my app.
Basically I have a bunch of images that if tapped will popup another view with that image and comments. Instead of using initWithTarget
using self
I want to call the function from a shared class that can be loaded into each type of Navigation Controller.
I am able to initialize ImageClass *imageClass = [[ImageClass alloc]init]
and call the functions fine by [imageClass DoThis]
however when I add it to a UITapGestureRecognizer the app crashes.
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:imageClass action:@selector(DoThis)];
Also if I include the DoThis
function and initWithTarget:self
everything works as expected however I'd like to not write the DoThis
function into every View Controller if possible I'd like it to fire directly from the UITapGestureRecognizer
.
Thanks in advance for any insight you can give me into what I'm doing wrong.
Alright basically I the imageClass object was getting deallocated every time a new image appeared. I moved that logic to the controller and all started working fine.
Thanks for helping out MSK!