Reputation: 655
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];
}
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
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
Reputation: 346
If didSelectRowAtIndexPath
is not getting then there may be one of the following reason.
UIView
which can respond to touch in the responder chain.allowsSelectionDuringEditing
is flase
.Upvotes: 5