UIButton在动画后没有响应 [英] UIButton not responding after animation

查看:107
本文介绍了UIButton在动画后没有响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望首先从下方链接下载该项目,然后继续问题(仅36kb)



下载。


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 like below.

When I click My Office button, I am calling action actionSeenButton which will print NSLog(@"actionSeenButton");

- (IBAction)actionSeenButton:(id)sender {
    NSLog(@"actionSeenButton");
}

This works perfect.

When I click, Show hidden button, I am sliding view by 100 and showing the image and buttons that I have at the top, as shown in below image

Code used is

- (IBAction)showHiddenButton:(id)sender {
    CGAffineTransform translation = CGAffineTransformIdentity;
    translation = CGAffineTransformMakeTranslation(0, 100);
    [UIView beginAnimations:nil context:nil];
    self.view.transform = translation;
    [UIView commitAnimations];
}

When I click this button, I am calling action actionHiddenButton which will print NSLog(@"actionHiddenButton");

- (IBAction)actionHiddenButton:(id)sender {
    NSLog(@"actionHiddenButton");
}

BUT the problem is, when I click the new button that I see, action is not getting called.

Any idea why this is happening?


Note

When I move the top hidden button from y=-70 to y=170, action is getting called.

Sample project can be downloaded from here

What I wanted to implement is, showing three buttons (as menu) on the top in one line by moving view down.

解决方案

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.

这篇关于UIButton在动画后没有响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆