The carousel uses a pan gesture recogniser to control the scrolling. If you get access to that gesture you can disable it (and then re-enable it again later).
Temporarily keep iCarousel from scrolling
-
01-07-2022 - |
Вопрос
Is there some way to prevent iCarousel from scrolling? Like, a "lock screen" feature? When i press a button, it should stop scrolling and when the button is pressed a second time, it'll start scrolling again. Is there any way to do this?
Решение
Другие советы
If you just want to prevent the user from interacting with the carousel then simply write
[carousel setUserInteractionEnabled:NO];
To start scrolling then the first button is pressed write:
-(IBAction) spinButton:(id)sender {
[carousel scrollByNumberOfItems:30 duration:10];
}
To stop scrolling then the second button is pressed write:
-(IBAction) stopButton:(id)sender {
[carousel scrollToItemAtIndex:[carousel currentItemIndex] animated:YES];
}
This is possible by:
[carousel setScrollEnabled:NO];
You can set this view property to NO:
@property(nonatomic, getter=isUserInteractionEnabled) BOOL userInteractionEnabled
It will disable touch handling of your carousel view.
Не связан с StackOverflow