动画iOS后按钮停止运行

动画iOS后按钮停止运行,ios,uiview,uianimation,Ios,Uiview,Uianimation,执行slide方法后,UIView上的按钮在调用该方法后停止工作 对可能发生的事情有什么想法吗 @implementation ResultSliderView - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { // Initialization code self.frame = CGRectMake(10,255,0,0);

执行slide方法后,UIView上的按钮在调用该方法后停止工作

对可能发生的事情有什么想法吗

@implementation ResultSliderView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        self.frame = CGRectMake(10,255,0,0);

    }
    return self;
}

/*
This method slides the view up by animating
*/
-(void)slideUp{
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:.5];
    [UIView setAnimationCurve:UIViewAnimationOptionAllowUserInteraction];
    self.frame = CGRectMake(5,38,0,0);
    [UIView commitAnimations];
}

您的视图大小为零,因此按钮将位于其框架之外——当按钮位于框架之外时,它们不会收到触摸(如果您的视图没有设置剪辑子视图,您仍然可以看到按钮)。

Genius。您是否还知道如何允许用户拖动视图,而不是自己设置视图?因此,就像滑块一样,如果我拖动,它会跟随,但如果我向上移动超过一半并松开,它会捕捉到顶部,否则会捕捉到底部?@waf,要做到这一点,您需要将平移手势识别器附加到视图,并使用其TranslationView属性更改帧以跟随移动。