Katushai
Katushai

Reputation: 1520

Temporarily keep iCarousel from scrolling

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?

Upvotes: 1

Views: 1836

Answers (4)

Syed Absar
Syed Absar

Reputation: 2284

This is possible by:

[carousel setScrollEnabled:NO];

Upvotes: 1

Christos Koninis
Christos Koninis

Reputation: 1678

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];    
}

Upvotes: 1

opedge
opedge

Reputation: 1542

You can set this view property to NO:

@property(nonatomic, getter=isUserInteractionEnabled) BOOL userInteractionEnabled

It will disable touch handling of your carousel view.

Upvotes: 0

Wain
Wain

Reputation: 119021

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

Upvotes: 3

Related Questions