bvogelzang / BVReorderTableView

Easy Long Press Reordering for UITableView
MIT License
234 stars 59 forks source link

Calling "canReorder" #20

Closed adamrushy closed 10 years ago

adamrushy commented 10 years ago
BVReorderTableView *reorder = [[BVReorderTableView alloc] init];
reorder.canReorder = NO;

It doesn't seem to be working for me, any clues?

bvogelzang commented 10 years ago

Hmm this could be a bug. Could you give me more info about what you're trying to do?

Are you trying to stop re-ordering all together i.e. re-ordering without the long press gesture? Using canReorder will only control long press re-ordering for the table. You have to use UITableView's delegate methods and properties to stop re-ordering all together.

adamrushy commented 10 years ago

I am going to remove re-ordering from 2 Sections in my UITableView.

For example;

if (indexPath.section == 0) { BVReorderTableView *reorder = [[BVReorderTableView alloc] init]; reorder.canReorder = NO; }

Is this the right approach?

bvogelzang commented 10 years ago

No that is not the right approach. canReorder is used to disable re-ordering globally and not on a row by row basis. You should be using the tableView:canMoveRowAtIndexPath: datasource method to control this. For example:

- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 0) {
        return NO;
    }
    return YES;
}
adamrushy commented 10 years ago

I already tried this previously, not working as it should do..