我在我的应用程序中有一个UIButtons的旋转木马菜单。除了按钮有点大以外,一切都很好,当手指拖过按钮时它不会滚动。拖动必须在旋转木马当前和中心的按钮之外完成。是否有一些设置可以更改,以便我可以在按钮上滑动以进行滚动并让它们也可以互动?如何允许通过UIButtons滑动滚动?
下面是一个创建按钮的代码:
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0, 0, 500.0f, 320.0f);
button.layer.cornerRadius = 8.0f;
button.layer.masksToBounds = NO;
button.layer.borderWidth = 0.0f;
button.layer.shadowColor = [UIColor blackColor].CGColor;
button.layer.shadowOpacity = 0.8;
button.layer.shadowRadius = 12;
button.layer.shadowOffset = CGSizeMake(12.0f, 12.0f);
[button setImage:(UIImage*)[buttons objectAtIndex:index] forState:UIControlStateNormal];
[button addTarget:self action:@selector(buttonTapped:) forControlEvents:UIControlEventTouchUpInside];
当手指拖动按钮时,按钮是第一响应者,所以按钮动作被触发。如果你想跳过按钮动作,你可能会更好地实现你自己的touchMoved,touchBegan,touchEnd代码 – Jing