سؤال

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?

هل كانت مفيدة؟

المحلول

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).

نصائح أخرى

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top