Naveen
Naveen

Reputation: 900

Need drag and drop a view in icarousel

I am using icarousel in my iPad application. I want a functionality like drag and drop of objects in that icarousel. Drag in a view out of the carousel to delete an item from it and drop a view in the carousel to add an item to in. I have downloaded icarousel from https://github.com/nicklockwood/iCarousel

I have tried the drag and drop functionality using the delegate methods

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event

but whole the view is messed up. please help me out here. thank you in advance.

Upvotes: 2

Views: 1054

Answers (2)

Firdous
Firdous

Reputation: 4652

All you need can be found in this sample project: https://github.com/firdousali86/SampleDragDropCarousel

Upvotes: 0

MobileVet
MobileVet

Reputation: 2958

This is kind of an old post, but just in case you are still stuck, here is what we do.

To pull a view out:

  1. Add a pan gesture recognizer to the iCarousel
  2. Mark the point of the touch on recognizerStateBegan
  3. Adjust the frame or transform of the view on recognizerStateChanged
  4. Check the location on recognizerStateEnded

    4.1 Return item if not fully out

    4.2 Delete item from data source if fully out

  5. Reload iCarousel

You can do something very similar to views that you drop on the iCarousel but in reverse.

Upvotes: 3

Related Questions