Tuesday, March 26, 2013

GMGridview long press delete and moving cell at same time

GMGridview is very essential library project for cell manipulation for iOS project which are moving cell and delete cell and etc.But I have seen there was a problem you can't add two animation with same time like when moving and delete animation with same time.

So i have changed it as i want ,


Problem is : long-press delete and moving cell same time.

Solution is : when you are long pressing,it active the delete mode then if you want delete cell ,you can delete  it , if you want to moving cell you can move cell but while moving delete mode is deactivate and after releasing cell delete mode also active again.

So i have create sub class of GMGridview and change the rules what you want.But some methods and variables are private So you should move in to GMGridview.h file .

Step 1  : Add properties to GMGridview header file 



And syntheses the this properties and remove private variable these name in GMGridview.h file.

 Step 2  : Add methods to GMGridview header file 

Step 3    : create sub class of GMGridview and changed rules as follow(GMGridViewSub)
Step 3.1 : Header file

















Step 3.2 : Implementation file(m)
Step 3.2.1 : Import header file and constant as follow 

















Step 3.2.2 : Add following init and function within implementation scope as follow

It first call super class function and then run remainder task.Change the valid rule as following code because it check without editing.


Longpress GestureUpdate : Add the moving editing animation as follow and
SortingMoveDidStart :  before start the moving edit mode is NO 





























Change following function Edditing is yes and after stop the animation changed it as

if(self.editing)
     self.sortMovingItem.editing =YES;
















While moving cell editing flag is NO








Now you have developed the sub class of GMGridView and then you can call the subclass as you want instead of GMGridView Add this reference as you wanted class as follow.

GMGridViewSub *gmGridView = [[GMGridViewSub alloc] init];