滚动延迟使用UIScrollView&多个UIButtons

时间:2014-10-10 14:00:48

标签: ios uiscrollview uibutton ios8

我有一个UIScrollView,它包含一个UIView,它还包含一行UIButtons。我最近注意到,当用户通过触摸UIScrollView左右滚动时,会有一个瞬间延迟。有时UIButton会检测到滑动,似乎会激活按钮。

- (void)setupScreen {

     CGRect screenRect = [[UIScreen mainScreen] bounds];
     CGFloat screenWidth = screenRect.size.width;
     CGFloat screenHeight = screenRect.size.height;
     [self.view setFrame:CGRectMake(0, 0, screenWidth, screenHeight)];

     [self.view addSubview:self.scrollViewControls];
     [self.scrollViewControls setFrame:CGRectMake(0, self.view.frame.size.height - self.scrollViewControls.frame.size.height, self.view.frame.size.width, self.scrollViewControls.frame.size.height)];
     [self.scrollViewControls addSubview:self.viewControls];
     [self.scrollViewControls setContentSize:CGSizeMake(self.viewControls.frame.size.width, self.viewControls.frame.size.height)];
     [self.scrollViewControls setBackgroundColor:[self colorWithHexString:@"333a44"]];
     self.scrollViewControls.delaysContentTouches = NO;

     self.imageCache = [[NSMutableDictionary alloc] init];

     [self setupImage];

}

我在iOS 7中没有注意到这个问题,它似乎是在iOS 8中。按下时所有按钮都设置为Touch Inside。

知道如何纠正这个问题吗?

2 个答案:

答案 0 :(得分:1)

scrollView.delaysContentTouches = NO

答案 1 :(得分:0)

搜索后,这是我的滚动问题的最佳解决方案。

See Answer