Shaik Tamim Shaik Tamim - 1 month ago 6
iOS Question

when i created table view programatically,didSelectRowAtIndexPath method not executed

created table view progamatically...

attatchmentTableView=[[UITableView alloc]initWithFrame:CGRectMake(attatchmentsLabel.frame.origin.x+200, attatchmentsLabel.frame.origin.y-20, issueHistoryTextView.frame.size.width, 100) ];

attatchmentTableView.scrollEnabled=YES;
//attatchmentTableView.userInteractionEnabled=YES;
attatchmentTableView.layer.borderColor = [UIColor purpleColor].CGColor;
attatchmentTableView.allowsSelectionDuringEditing=YES;
attatchmentTableView.layer.cornerRadius = 10.0f;
attatchmentTableView.allowsSelection=YES;
attatchmentTableView.layer.cornerRadius=4;
attatchmentTableView.layer.borderWidth=3.0f;
attatchmentTableView.delegate=self;
attatchmentTableView.dataSource=self;
[createIssueView addSubview:attatchmentTableView];


and impletemented table view
datasource
and
delegate
methods, but unable to call
didSelectRowAtIndexPath
method.

So any one can help in this issuance..Thanks in advance

Zeb Zeb
Answer

Probably it is useless, but just try to add userinteractionenabled = true. Or try bringSubviewToFront. Do you have other tableView or GestureRecongnizer?

UPDATE

When the tableView:didSelectRowAtIndexPath method is not called, there many things you can check:

  • UITableViewDelegate correctly set
  • Single Selection not enabled
  • Other gesture UIGestureRecongnizer in the same controller

In this last case, the solution depends on what you need. The fastest solution is to enable both simultaneously with this code:

yourGestureRecognizer.cancelsTouchesInView = false;

Otherwise, take a look at the UIGestureRecognizerDelegate.

Comments