动画时滚动视图按钮操作不起作用

时间:2016-06-15 07:03:11

标签: ios uiscrollview uibutton core-animation uianimation

UIButtons中添加了10 UIScrollView。写道使用UIAnimation自动滚动滚动视图代码。

for (int i=0; i<10; i++) {

    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(XPosition, YPosition, width,50);
    [button setTitle:@"Warning animation items array " forState:UIControlStateNormal];
    button.tag = i;
    [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];

    if (index%2) {
        button.backgroundColor = [UIColor blueColor];
    } else{
        button.backgroundColor = [UIColor purpleColor];
    }
    XPosition = paddingSpace + XPosition + button.frame.size.width;
    [_scroll addSubview:button];
    index++;
}
_scroll.contentSize=CGSizeMake(XPosition,50);

动画UIScrollView时,我无法点按任何UIButton !!!

[UIView animateWithDuration:20
                      delay:0.0
                    options:(UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionRepeat)
                 animations:^{
                     _scroll.contentOffset = CGPointMake(XPosition, 0.0);
                 } completion:^(BOOL finished){}];

如果动画停止,我可以点按UIButton

请帮我解决这个问题。

1 个答案:

答案 0 :(得分:0)

你可以使用scrollview.userintreactionenable = yes; 我认为这对你有帮助