didSelectRowAtIndexPath确实不起作用

时间:2012-08-27 19:00:20

标签: objective-c uitableview didselectrowatindexpath

didSelectRowAtIndexPath无效。
我配置了2个代表吗?一切都是联系在一起的(tableview,tableviewcell) 已经删除并再次执行。
我在这里搜索了一切,没有任何效果 我认为这是最好的link之一,但仍无济于事。

我最后的希望是,我正在打开我的ViewController,这里有这个tableview,用于模态。但这个问题非常错误。

除此之外,我需要一些帮助

Somo代码.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

部分代码.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..........
}

2 个答案:

答案 0 :(得分:4)

我谦卑地向所有人道歉! 我无意中点击了属性检查器&gt;选择:没有选择

所以我在代码中找不到任何内容。

再一次,我向所有人道歉,但如果有人遇到这个问题,这又是一个需要验证的步骤。 “更改为属性检查器&gt;选择:单个选择或多个选择(取决于您)

感谢大家的答案和帮助

答案 1 :(得分:1)

你在didSelectRowAtIndexPath设置了休息时间吗?试着看看它是否在那里成功破裂。

扩展rokjark的答案,您必须手动将委托和数据源设置为相关文件。

您的标题文件simulator.h只是将其声明为 A UITableView的 A 委托/数据源。

您仍然需要指出table_menu_left使用simulator.h作为 委托文件来处理所有回调。

集:

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

再次在didSelectRowAtIndexPath中设置一个中断,看看它是否被调用。

相关问题