Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8754297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:35:30+00:00 2026-06-13T13:35:30+00:00

Somebody help! Here is what I want to implement : While an UIImageView is

  • 0

Somebody help!

Here is what I want to implement :

  • While an UIImageView is becoming alpha 0 (hidden)
  • it can be touched
  • so that its alpha becomes one (unhidden).

But UIImageView is not touched while it is animating (=becoming alpha 0).

I tried hundred skills at stackoverflow, but didn’t work.

They are…….

  1. UIViewAnimationOptionAllowUserInteraction
  2. setUserInteractionEnabled:YES;
  3. touchesBegan
  4. GestureRecognizer options
  5. etc..

Only function ‘hitTest’ worked but not during animation.

Please reply . Thank you.
Below is my codes.

#import "ViewController.h"
#define AD @"text.png"
#import <QuartzCore/QuartzCore.h>

@interface ViewController ()

@end

@implementation ViewController


@synthesize scrollData=_scrollData;
@synthesize adImage=_adImage;



   - (void)viewDidLoad
    {
        //_adImage is UIImageView
        _adImage=[[adImage alloc] initWithImage:[UIImage imageNamed:AD]];
_scrollData.scrollView.delegate = self;

    UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(singleTapGestureCaptured:)];

        [_adImage addGestureRecognizer:singleTap];
        [_adImage setMultipleTouchEnabled:YES];
        [_adImage setUserInteractionEnabled:YES];

        [self.view addSubview:_adImage];
        _adImage.alpha=0;
        [_adImage setUp_pt:CGPointMake(160,250)];
        _adImage.center=_adImage.up_pt;

        [super viewDidLoad];
        [self hideImage:_adImage delay:0];
        [self becomeFirstResponder];
    }


    - (void)hideImageComplete:(UIView*)v
    {
        [self hideImage:v delay:0];
    }

    - (void)hideImage:(UIImageView*)v delay:(int)nDelay
    {
        [_adImage becomeFirstResponder];

        [UIView animateWithDuration:1
                              delay:nDelay
                            options:
         (UIViewAnimationOptionCurveEaseIn | UIViewAnimationOptionAllowUserInteraction)
                         animations: ^
         {
                 _adImage.alpha=0.0f;
         }
                         completion:^(BOOL completed){
                             [self hideImageComplete:v];
                         }];
    }

- (void)singleTapGestureCaptured:(UITapGestureRecognizer *)gesture
{
    NSLog(@"Gesture event on view");
    _adImage.alpha=1;
}

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
    return YES;
}

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
    return YES;
}




- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
    NSLog(@"hit!!");
    [super touchesBegan:touches withEvent:event];
    UITouch *touch = [touches anyObject];
    CGPoint touchPoint = [touch locationInView:self.view];
    CGPoint touchLocation = [touch locationInView:self.view];
    _adImage.alpha=1;

}


@end



@implementation adImage
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [touches anyObject];
    CGPoint touchPoint = [touch locationInView:self];
    if ([[[self layer] presentationLayer] hitTest:touchPoint]) {
        [self.layer removeAllAnimations];
    }
}
-(UIView*)hitTest:(CGPoint)point withEvent:(UIEvent *)event{
    if ([[self.layer presentationLayer] hitTest:point]) {
        NSLog(@"hit!!");
        self.alpha=1;
        return self;
    }
    return [super hitTest:point withEvent:event];
}

@synthesize up_pt;


@end

Here is my ViewController.h codes.

#import <UIKit/UIKit.h>


@interface adImage : UIImageView {
}


//@property (strong, nonatomic) UIImageView *imageView;

@property (assign)CGPoint up_pt;


@end



@interface ViewController : UIViewController <UIScrollViewDelegate>{
}

- (void)hideImageComplete:(UIView*)v;
- (void)hideImage:(UIView*)v delay:(int)nDelay;

@property (strong, nonatomic) adImage *adImage;
@property(nonatomic, strong) IBOutlet UIWebView *scrollData;


@end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T13:35:31+00:00Added an answer on June 13, 2026 at 1:35 pm

    I have the answer for you, but first:

    • always name a class with a starting capital letter, ie AdImageView (its an image view not a pure view subclass too)

    • I took your code but commented out all your touch methods, which you may or may not need

    • the root issue here is that a UIGestureRecognizer won’t work if alpha is 0, so you will see the animation to alpha=0 is broken into two pieces, almost to 0, then to 0. If the user taps to cancel, then the final completion block returns the view to 0

    Code:

    - (void)hideImage:(UIImageView*)v delay:(int)nDelay
    {
        //[_adImage becomeFirstResponder];
    
        [UIView animateWithDuration:(3.0f - 0.1f)
                              delay:nDelay
                            options: (UIViewAnimationOptionCurveEaseIn | 
                                      UIViewAnimationOptionAllowUserInteraction)
                         animations: ^
         {
                 _adImage.alpha=0.1f;
         }
                         completion:^(BOOL completed)
                         {
                            NSLog(@"completed=%d", completed);
                            if(completed) {
                                [UIView animateWithDuration:0.1f animations:^{
                                    _adImage.alpha=0.0f;
                                }];
                            } else {
                                _adImage.alpha=1;
                            }
                         }];
    }
    
    - (void)singleTapGestureCaptured:(UITapGestureRecognizer *)gesture
    {
        NSLog(@"Gesture event on view");
        [_adImage.layer removeAllAnimations];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I hope somebody can help here, its an ongoing issue with no obvious solution.
I hope somebody can help me here, I have a table that has the
Hopefully somebody can help me out here. I'm working within an embedded ActionScript2 and
Can somebody help me to set diferent styles to firstchild and lastchild? I want
Can somebody help me to solve the problem, that my collapsible FieldSet won't remove
Hopefully somebody can help me out here. I have a UIView with 3 text
Can somebody please help me? I want to do a simple style for the
Can somebody help me with this. There is HTML code: <h3> <label> <input type=checkbox
Can somebody help me to suggest how can I get the play list from
can somebody help me and tell me why I can't center the JQuery UI

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.