Note that there are some explanatory texts on larger screens.

plurals
  1. POIOS - animation not responding
    primarykey
    data
    text
    <p>I want to create an animated menu. </p> <ul> <li>first it's hidden outside screen</li> <li>when user taps the screen, it will slide in</li> <li>user can tap it and it do something</li> <li>then after 3s it will slide outside screen</li> </ul> <p>But problem is it not response when I tap it. Why?</p> <p>example code: All code is in my UIView class.</p> <pre><code>showing = NO; box = [[UIView alloc] initWithFrame:CGRectMake(500,-200,200,200)]; box.backgroundColor = [UIColor redColor]; UITapGestureRecognizer *tapBox = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapMenuHandler:)] autorelease]; [box addGestureRecognizer:tapBox]; [self addSubView:box]; </code></pre> <p>and:</p> <pre><code>-(void) tapMenuHandler: (UIView *)obj { //Do something NSLog(@"tap box"); } </code></pre> <p>and:</p> <pre><code>-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { if (!showing) { box.frame = CGRectMake(500, -200, 200, 200); [UIView animateWithDuration:0.5f delay:0.3f options:(UIViewAnimationOptionAllowUserInteraction) animations:^{ box.frame = CGRectMake(500, 200, 200, 200); } completion:^(BOOL finished) { showing = YES; [UIView animateWithDuration:0.5f delay:3.0f options:(UIViewAnimationOptionAllowUserInteraction) animations:^{ box.frame = CGRectMake(500, -200, 200,200); } completion:^(BOOL finished) { showing = NO; }]; }]; } </code></pre> <p>}</p> <p>Thank for your help and sorry for my English :)</p> <p>Edit: more detail I tried set start my box's origin in screen (ex. 500,600), It still always response when tap at start point (500,600) even though my box move to another position.</p> <p>Update: I changed my way to move box outside screen by use NSTimer then it's work!</p> <pre><code>[UIView animateWithDuration:0.5f delay:0.3f options:UIViewAnimationOptionAllowUserInteraction animations:^{ box.frame = CGRectMake(500,200,200,200); } completion:^(BOOL finished) { isShowMenubar = YES; //use NSTimer instead of delay [NSTimer scheduledTimerWithTimeInterval:3.0f target:self selector:@selector(hideBox) userInfo:nil repeats:NO]; }]; </code></pre> <p>and </p> <pre><code>-(void)hideBox { [UIView animateWithDuration:0.5f delay:0.0f options:UIViewAnimationOptionAllowUserInteraction animations:^{ box.frame = CGRectMake(500,-200,200,200);} completion:^(BOOL finished) { isShowMenubar = NO; }]; } </code></pre>
    singulars
    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.
 

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