gmoledina / GMGridView

A performant Grid-View for iOS (iPhone/iPad) that allows sorting of views with gestures (the user can move the items with his finger to sort them) and pinching/rotating/panning gestures allow the user to play with the view and toggle from the cellview to a fullsize display.
MIT License
2.3k stars 512 forks source link

How can I move (change the position ) + delete the the cells using long press #126

Open nfs3250 opened 12 years ago

nfs3250 commented 12 years ago

First of all Thanks for very useful & awesome library. My questions are

1) How can I move the cells & also delete the cells using Long Press ? I want to give both moving + deleting functionality same as iOS spring board in my app.

2) I have added one more UIView(gridContentView) in my UIViewController. Now I want to show GMGridView in gridContentView. I tried setting gmGridView.mainSuperView = self.gridContentView; but still my grids scroll above that view. How can I change mainSuperView ?

Any kind of help is appreciated. Thanks in advance

trawor commented 12 years ago

+1

2) I have added one more UIView(gridContentView) in my UIViewController. Now I want to show GMGridView in gridContentView. I tried setting gmGridView.mainSuperView = self.gridContentView; but still my grids scroll above that view. How can I change mainSuperView ?

Maverick1st commented 12 years ago

Why do you need a containerView for the Gridview? You can just set the frame of the GridView if you want it to be smaller. And be sure to set clipsToBounds = YES to avoid cells being displayed out of the gridviews bounds.

Maverick1st commented 12 years ago

Regarding your 1st Point. Have you tried to set your gridview to editing mode in the handle method of the longPressGestureRecognizer? Should work if you do the same as in the Example. Like calling

- (void)editingSwitchChanged:(UISwitch *)control
{
    self.gridView.editing = control.on;
    control.on = self.gridView.isEditing;
    [self.gridView layoutSubviewsWithAnimation:GMGridViewItemAnimationFade];
}
trawor commented 12 years ago

@Maverick1st thx for reply, I had try clipsToBounds = YES in the example code it should be _gmGridView1.clipsToBounds=YES; but it does work as I wish, it still looks like this: screenshot

nfs3250 commented 12 years ago

@trawor , I tried the above solution of setting required frame & then using clipToBounds = YES & it works perfectly. Here is my code if you need it

-(void)setUpGridView { NSInteger spacing = 8; GMGridView *tempgmGridView = [[GMGridView alloc] initWithFrame:CGRectMake(0.0, 60.0, 320.0, 352.0)]; tempgmGridView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; tempgmGridView.backgroundColor = [UIColor clearColor]; [self.view addSubview:tempgmGridView]; gmGridView = tempgmGridView; gmGridView.clipsToBounds = YES; gmGridView.style = GMGridViewStyleSwap; gmGridView.itemSpacing = spacing; gmGridView.minEdgeInsets = UIEdgeInsetsMake(spacing, spacing, spacing, spacing); gmGridView.centerGrid = YES; gmGridView.actionDelegate = self; gmGridView.sortingDelegate = self; gmGridView.transformDelegate = self; gmGridView.dataSource = self; }

Now my GridView scrolls within the frame. Try to set FRAME of GMGridView also along with clipToBounds = YES

nfs3250 commented 12 years ago

@Maverick1st Thanks for reply. I tried to set gridview to editing mode in the handle method of the longPressGestureRecognizer as follows

}

But it works for first time & afterwards its not working because

// Editing Mode @property (nonatomic, getter=isEditing) BOOL editing; // Default is NO - When set to YES, all gestures are disabled and delete buttons shows up on cells

Can you tell me what should I do ?

Maverick1st commented 12 years ago

What do you do, when you want to leave editing mode? Of course you have to reset all variables to the state they were before entering editing mode. It seems to me, that you have missed something.

nfs3250 commented 12 years ago

I am not getting what I am doing wrong. Where should I reset & which variables ? Sorry. Can you tell me what I need to do? Thanks

Maverick1st commented 12 years ago

I cannot help you, when you are not answering my questions ;). What do you do, when you want to leave editing mode? Do push a button, or what? When you have entered Editing mode Gestures are disabled, so that you cannot accidentally trigger the tap or the pan action, i guess. So since you are in editing mode and the longPressGesture is disabled you have to return to non-editing state via a buttonpress. Of course you have to create the button by yourself. Just look at the examples. It should be much clearer then.

And of course it is always better not to just use the code some one gives you, but to understand it. I know this is a lot of work, but it will massively improve your programming skills :).

chadpod commented 12 years ago

I took a crack at this one, as well as merging #47 in my fork of GMGridView. I'll submit a pull request once I have a chance to test more. Feel free to test it out and let me know if you have any feedback.

https://github.com/shacked/GMGridView

asankamadushan commented 11 years ago

How can i enable long press gesture enable on edit mode ?

chathurka commented 11 years ago

This is a solution for above problem http://roshankularathna.blogspot.com/2013/03/gmgridview-long-press-delete-and-moving.html