Rani
Rani

Reputation: 3453

tableview didselectrowatindex path is not getting called in iOS

I have a custom uiview to which I am adding tableview as my subview. I have created tableview programatically. When I click on my button tableview is displayed with the populated list but the problem is didselectrowatindexpath is not getting called. cellforrowatindexpath is getting called.

This is my code

-(void)viewDidLoad
{
tblNetBanking = [self makeTableView];
     [self.tblNetBanking registerClass:[UITableViewCell class] forCellReuseIdentifier:@"newFriendCell"];
    [self.customview addSubview:tblNetBanking];
}

-(UITableView *)makeTableView
{
    CGFloat x = 0;
    CGFloat y = 0;
    CGFloat width = self.view.frame.size.width;
    CGFloat height = self.view.frame.size.height - 50;
    CGRect tableFrame = CGRectMake(x, y, width, height);

    UITableView *tableView = [[UITableView alloc]initWithFrame:tableFrame style:UITableViewStylePlain];

    tableView.rowHeight = 45;
    tableView.sectionFooterHeight = 22;
    tableView.sectionHeaderHeight = 22;
    tableView.scrollEnabled = YES;
    tableView.showsVerticalScrollIndicator = YES;
    tableView.userInteractionEnabled = YES;
    tableView.bounces = YES;

    tableView.delegate = self;
    tableView.dataSource = self;

    return tableView;
}
//and on my button click
-(IBAction)netbanking
{
    tblNetBanking.hidden=NO;
    txtCreditCardNumber.hidden=YES;
    btnNetBankingCancel.hidden=NO;

    txtCreditExpiryDate.hidden=YES;
    txtCreditNickName.hidden=YES;
    btnCreditCardSave.hidden=YES;
    btnScanCreditCardNo.hidden=YES;
    txtDebitCardNumber.hidden=YES;
    txtDebitExpiryDate.hidden=YES;
    txtDebitNickName.hidden=YES;
    btnScanDebitCardNo.hidden=YES;
    btnDebitCardSave.hidden=YES;

}

Upvotes: 0

Views: 138

Answers (2)

Krivoblotsky
Krivoblotsky

Reputation: 1502

Are you using any gesture recognizers on this screen?

In some cases, UIGestureRecognizers intercept touches and selection and this delegates wont called.

Upvotes: 1

Alex Albu
Alex Albu

Reputation: 733

After Interface MyClass make sure you have <UITableViewDelegate, UITableViewDataSource>. Also, if you wrote the code for DidSelectRowAtIndexPath check if you have any typos.

Can we see your DidSelectRowAtIndexPath code?

Upvotes: 0

Related Questions