Raghav
Raghav

Reputation: 655

UITableView delegate is not getting called

I am using the UITableView in a menu drawer and changing the place of the UITableView upon clicking the menu button.

The UITableViewDataSource is working, the UITableViewDelegate are not working. I set the delegate from story board and inside view controller still the didSelectRowAtIndexPath is not getting called.

-(void) showMenu{
isMenuShown = YES;
        [_drawerButton setImage:[UIImage imageNamed:@"v_drawer_menu"]];
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:0.5];
        self.view.frame = CGRectMake(220, self.view.frame.origin.y, self.view.frame.size.width, self.view.frame.size.height);
        _tableView.frame = CGRectMake(0, self.view.frame.origin.y, 220, self.view.frame.size.height);
        self.menuView.frame = CGRectMake(0, self.view.frame.origin.y, 220, self.view.frame.size.height);
        _menuView.userInteractionEnabled = YES;
        _tableView.userInteractionEnabled = YES;
        _tableView.delegate = self;

        [UIView commitAnimations];
}

The view and table view I am moving them upon toggle. Help appreciated.

The issue is RESOLVED,

I was moving the base view so all interactions were on base with with x position from 220 hence the table view interactions were not working, I changed the view hierarchy in story board and used the bringSubviewToFront method of view to make it working.

Thank you :)

Upvotes: 0

Views: 1949

Answers (2)

cyberlobe
cyberlobe

Reputation: 1781

You need to check few things:

  • It some time happens that if we have copied tableview from some other viewcontroller than delegate & datasource links will be already there but pointing to that old view controller. So need to remove the link & again make connection

  • Also make sure You have not put UITableViewDelegate protocol in your .h file as because you already linked on storyboard

  • If still it not work than clean your project & remove delegate method, than put cursor on UITableview Press window key. You will be redirected to the page of delegate methods of tableview & copy delegate method from it & place it in your code.

(Note: Do not copy delegate methods from any where, its good practice to direct copy it from delegate section page).

Hope this will help you to resolve the issue.

Upvotes: 0

SS Akhtar
SS Akhtar

Reputation: 346

If didSelectRowAtIndexPath is not getting then there may be one of the following reason.

  1. delegate is not set. This I understand is set properly to the file owners.
  2. There may be a UI control in the table view cell which is as same size as the cell.
  3. A UIView which can respond to touch in the responder chain.
  4. Or may be the table view is allowsSelectionDuringEditing is flase.

Upvotes: 5

Related Questions