0

I am new in iOS.

I want to use Today extension. I have created Today extension and add uitableview it works fine. but when I try to select row then delegate Method DidSelectRowAtIndexPath doesn't call.

In my code there are 3 methods of uitableview delegate and datasources.

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
  return 3;
}

 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
   {
      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyIdentifier"];

if (cell == nil) {
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"MyIdentifier"];
}

cell.textLabel.text = [NSString stringWithFormat:@"Hello World%li",(long)indexPath.row];
return cell;

}

   - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
      return 1;
     }

Above Datasources Method call correctly

but didselect row method doesn't call after selection of row.

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
     {
       NSLog(@"row Selected");
     }

appreciate for help.

Vinod Jadhav
  • 1,055
  • 1
  • 15
  • 37

2 Answers2

1

You mention that the data source methods are called. But tableView: didSelectRowAtIndexPath: is a UITableViewDelegate method, not a data source method. It looks like the table view's delegate property might not be set.

Tom Harrington
  • 69,312
  • 10
  • 146
  • 170
0

Implement UITableViewDelegate protocol in your table View class same as UITableViewDataSource is implemented. didSelectRowAtIndexPath will work fine i.e will be called when a row from table is selected.

Ankit Kapoor
  • 1,615
  • 12
  • 18