Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Open
nfs3250 opened this Issue · 12 comments

6 participants

nfs3250 Travis Maverick1st Chad Podoski Asanka Madushan Perera chathurka
nfs3250

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

Travis

+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

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

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

@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

@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

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

  • (void)longPressGestureUpdated:(UILongPressGestureRecognizer *)longPressGesture
    {

    self.editing = YES;
    self.enableEditOnLongPress = YES;
    // Remaining code in this method

}

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

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

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

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

Chad Podoski

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

Asanka Madushan Perera

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.