“moveRowAtIndexPath” is called if I select a row or move a uitableview

I need to detect between didSelectRowAtIndexPath and moveRowAtIndexPath method of UITableView button but i figure out that when i set [myTableView setEditing:YES animated:YES] at ViewDidLoad then whether i select or move on cell it always into moveRowAtIndexPath. I really want to detect two this methods to have different treatments when tap or move on cell.

this is my code:

- (void)viewDidLoad {
    [super viewDidLoad];
    [HomeTableView setEditing:YES animated:YES];
    [HomeTableView setScrollEnabled:NO];
}

- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath {
    //it's always get here when i select on cell
    //do something here
}

- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 0) // Don't move the first row
    {
        return NO;
    }
        return YES;
}

-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    return YES;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    //i wanna do thing here but it's never into this method when i set [HomeTableView setEditing:YES animated:YES];
}

Any help is appreciable. Thanks in advance...

Answers


You need to set the allowsSelectionDuringEditing property of UITableView to true..

self.tableView.allowsSelectionDuringEditing=YES;

Need Your Help

iOS: Sense small device vibrations - e.g. Sleep monitoring apps

objective-c ios cocoa-touch uiaccelerometer

I am wanting to have my device sense small vibrations, such as a small shake, or someone breathing. I am assuming that this is possible because the app store has a number of "Sleep Pattern Monitor"

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.