【问题标题】:Scroll view button action is not working when animating动画时滚动视图按钮操作不起作用
【发布时间】:2016-10-16 03:28:49
【问题描述】:

UIScrollView 中添加了 10 个UIButtons。使用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

请帮帮我。

【问题讨论】:

  • 放上你的动画代码。
  • 为什么可以使用带有 10 个按钮的滚动视图。您可以使用 tableview 并重用相同的按钮是一种更好的方法。分享你的代码
  • 需要反复垂直滚动。滚动动画时我需要点击

标签: ios uiscrollview uibutton core-animation uianimation


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-19
    • 2020-10-24
    • 1970-01-01
    • 2020-06-19
    • 1970-01-01
    • 2016-03-21
    相关资源
    最近更新 更多