UIButton not responding after animation

后端 未结 3 1638
萌比男神i
萌比男神i 2021-01-13 11:14

I would prefer first download the project from below link and then continue with question (only 36kb)

Download Link

At start what I have is

3条回答
  •  一生所求
    2021-01-13 11:41

    Yipeee!!! Below is how I did.

    .h

    Added new variable.

    @property (retain, nonatomic) NSString *hideStatus;
    

    .m

    -(void) viewDidAppear:(BOOL)animated {
        NSLog(@"viewDidAppear");
        CGAffineTransform translation = CGAffineTransformIdentity;
        translation = CGAffineTransformMakeTranslation(0, -100);
        self.view.transform = translation;
        self.view.clipsToBounds = YES;
        [UIView commitAnimations];
        self.view.frame = CGRectMake(0,-80,320,560);
        hideStatus = @"hidden";
    }
    
    - (IBAction)showHiddenButton:(id)sender {
        NSLog(@"hideStatus===%@", hideStatus);
        CGAffineTransform translation = CGAffineTransformIdentity;
        if ([hideStatus isEqualToString:@"hidden"]) {
            translation = CGAffineTransformMakeTranslation(0, 0);
            hideStatus = @"shown";
        } else {
            translation = CGAffineTransformMakeTranslation(0, -100);
            hideStatus = @"hidden";
        }
    
        [UIView beginAnimations:nil context:nil];
        self.view.transform = translation;
        self.view.clipsToBounds = YES;
        [UIView commitAnimations];
    }
    

    Attached is the sample project. You can download from here.

提交回复
热议问题