1

environment: Xcode 6.1.1 ;Storyboard issue: I'm creating some list with UITableView embed in a UIViewContrller instoryboard ,and all the cell can't be selected by click,but can be selected by long press unexpectedly. I don't know why and I can't figure it out . I hope someone help me . Thinks.


    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        HBillCell *cell = [tableView dequeueReusableCellWithIdentifier:@"billCell"];
        [cell loadInfo:self.dataSource[indexPath.row]];
        return cell; 
    }
    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
        [self performSegueWithIdentifier:@"bill2detail" sender:nil];
    } 

  • Are you using the delegate method: didSelectRowAtIndexPath ? – saurabh Mar 08 '15 at 15:07
  • Noone will help you as long as you don't show a bit of code... – Grzegorz Krukowski Mar 08 '15 at 15:08
  • @sasquatch Yes ,I'd linked the dataSource delegate and tableview delegate, and all the data can display correct,just only longpress can trigger didSelecteRowAtIndexPath to be called. – Jiafan Zhang Mar 08 '15 at 15:28
  • @grzegorz-krukowski The code is really simple .Just :
    
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        HBillCell *cell = [tableView dequeueReusableCellWithIdentifier:@"billCell"];
        [cell loadInfo:self.dataSource[indexPath.row]];
        return cell;
    }
    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
        [self performSegueWithIdentifier:@"bill2detail" sender:nil];
    }
    
    – Jiafan Zhang Mar 08 '15 at 15:32
  • 2
    Do not put code in comments, it's hard to read. Edit your question to include properly formatted code. – rdelmar Mar 08 '15 at 17:01
  • There's nothing in the code you posted that would cause this problem. What are you doing in loadInfo:? – rdelmar Mar 09 '15 at 04:49
  • @rdelmar Just load data and display.That's why this problem makes me confused.All tableviews in my storyboard got this problem ,I guess there's something wrong global.But I don't know what . – Jiafan Zhang Mar 09 '15 at 06:14

1 Answers1

6

Thank you all.This problem comes up because of the tap gesture added on the root view of view controller in the base class by myself.

- (void)viewDidLoad {
    [super viewDidLoad];
    UITapGestureRecognizer *tgr = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapBlankAction:)];
    tgr.delegate = self;
    [self.view addGestureRecognizer:tgr];
}

I'd figured it out.