Note that there are some explanatory texts on larger screens.

plurals
  1. POUITapGestureRecognizer EXC_BAD_ACCESS in self-contained UIView subclass
    primarykey
    data
    text
    <p>I've used UITapGestureRecognizer tons of times, but in this case I'm getting EXC_BAD_ACCESS when a tap occurs. I think it has to do with the fact that I'm adding it to an Alert-type overlay view. And for some reason the overlay view isn't getting retained even though it's on-screen.</p> <p>I'm creating the view like this:</p> <pre><code>HelperView *testHelper = [HelperView helperWithBodyText:@"test text"]; [testHelper presentAtPoint:screenCenter]; </code></pre> <p>The convenience method in HelperView.m looks like this:</p> <pre><code>+ (id)helperWithBodyText:(NSString*)text { return [[self alloc] initWithFrame:CGRectZero bodyText:text]; } </code></pre> <p>And the rest of the code looks like this:</p> <pre><code>- (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { self.container = [[AGWindowView alloc] initAndAddToKeyWindow]; self.container.supportedInterfaceOrientations = UIInterfaceOrientationMaskLandscapeRight; self.overlay = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)]; self.overlay.backgroundColor = [UIColor redColor]; self.overlay.alpha = 0.6; [self.container addSubviewAndFillBounds:self.overlay]; //this fills the screen with a transparent red color, for testing UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissMe:)]; [self.overlay addGestureRecognizer:tap]; //I want to dismiss the whole view if the overlay is tapped self.content = [[UIView alloc] initWithFrame:CGRectZero]; } return self; } - (id)initWithFrame:(CGRect)frame bodyText:(NSString*)bodyText { self = [self initWithFrame:frame]; if (self) { //TEST frame self.content.frame = CGRectMake(0, 0, 217, 134); // Initialization code UIImage *bgImage = [[UIImage imageNamed:@"helper-bg"] resizableImageWithCapInsets:UIEdgeInsetsMake(30, 28, 20, 20)]; UIImageView *bgImgView = [[UIImageView alloc] initWithImage:bgImage]; bgImgView.bounds = self.content.frame; [self.content addSubview:bgImgView]; } return self; } - (void)presentAtPoint:(CGPoint)loc { CGPoint newPoint = [self.container convertPoint:loc toView:self.container]; self.content.center = newPoint; [self.container addSubview:self.content]; } - (void)dismissMe:(UITapGestureRecognizer*)recognizer { //this never happens - I get EXC_BAD_ACCESS when I tap the overlay } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload