0

The didSelectRowAtIndexPath not working.
Have I configured the 2 delegates. Everything is linked (tableview, tableviewcell).
Already deleted and did it again.
I searched for everything here and nothing worked.
I think this was one of the best link, still to no avail.

My last hope is that it is, I'm opening my ViewController, where has this tableview, for modal. But it would be VERY wrong the problem.

Other than that, I need some help

Somo codes .H

@interface simulator : UIViewController <UITableViewDelegate, UITableViewDataSource, UIScrollViewDelegate>
{
   NSArray                                          *array_products;
}
@property (nonatomic, strong) NSDictionary          *plist_products;
@property (nonatomic, strong) IBOutlet UITableView  *table_menu_left;
@property (nonatomic, strong) NSString              *file_plist;

@end

Some codes .M

#import "cel_products.h"

- (void)viewDidLoad
{
   NSString *path_root      = [[NSBundle mainBundle] bundlePath];
   NSString *full_path      = [path_root stringByAppendingPathComponent:self.file_plist];
   self.plist_products      = [[NSDictionary alloc] initWithContentsOfFile:full_path];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
   static NSString *CellIdentifier = @"id_cell_products";
   UITableViewCell *cell           = [self.table_menu_left dequeueReusableCellWithIdentifier:CellIdentifier];

   array_products                  = [self.plist_produtcs allKeys];
   if (cell == nil)
   {
       NSArray *topLevelObjects    = [[NSBundle mainBundle] loadNibNamed:@"cel_products" owner:self options:nil];

       for(id currentObject in topLevelObjects)
       {
           if([currentObject isKindOfClass:[cel_products class]])
           {
               cell = (cel_products *)currentObject;
               break;
           }
       }
   }
   cell.textLabel.text       = [array_products objectAtIndex:indexPath.row];
   return cell;
}

// numberofrowsinsection - OK
// numberofsectionintableviw - OK

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
   NSLog(@"Hein?????");
   // Nothing..........
}
Community
  • 1
  • 1
Daniel Arantes Loverde
  • 2,317
  • 2
  • 28
  • 41

2 Answers2

4

I humbly thousand apologies to all! I inadvertently clicked Attributes Inspector> Selection: NO SELECTION

So I do not find anything in the code.

Again, I apologize to everyone, but if someone, are having this problem, this is one more step to be verified. " Change to Attributes Inspector> Selection: SINGLE SELECTION or MULTIPLE SELECTION ( is up to you )

Thanks all for the answers and help

Daniel Arantes Loverde
  • 2,317
  • 2
  • 28
  • 41
  • please answer you own question! Like this questions are kept open and popping up in unanswered. – Roger Dec 14 '12 at 10:01
1

Did you set a break at didSelectRowAtIndexPath? Try and see if it breaks successfully there.

Expanding on rokjark's answer you have to manually set the delegate and data source to the file in question.

Your header file simulator.h simply declares it as A delegate/data source for SOME UITableView.

You still need to point table_menu_left to use simulator.h as THE delegate file to handle all of it's callbacks.

Set:

self.table_menu_left.delegate = self;
self.table_menu_left.datasource = self;

And again set a break in didSelectRowAtIndexPath and see if it gets called.

Community
  • 1
  • 1
samuelsaumanchan
  • 617
  • 1
  • 5
  • 10
  • i set a brak, and does not enter on this method. All delegates are seted and all IB conector are seted. I have 4 apps using same scheme of this tableview code, all works perfect, 1 of them use 2 tableviews on the same code, work perfect. Only difference on this project, is that open a view as modal. Only that is different. Pretty wired!!! – Daniel Arantes Loverde Aug 28 '12 at 13:39
  • So you're opening the view through a modal segue? Did you set the delegate (or delegates if you have multiple `UITableViews`) properly in the `prepareForSegue` in the view you're segueing from? – samuelsaumanchan Aug 29 '12 at 05:27
  • i do no use historyboard... but i answer with the solution ;) – Daniel Arantes Loverde Aug 29 '12 at 14:57