我有一个自定义uiview,我将tableview添加为我的子视图。我以编程方式创建了tableview。当我点击我的按钮时,会显示填充列表的表视图,但问题是没有调用didselectrowatindexpath。 cellforrowatindexpath正在被召唤。
这是我的代码
-(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;
}
答案 0 :(得分:1)
您是否在此屏幕上使用任何gesture recognizers
?
在某些情况下,UIGestureRecognizers
拦截触摸和选择,此代表不会调用。
答案 1 :(得分:0)
Interface MyClass
后确保您拥有<UITableViewDelegate, UITableViewDataSource>
。
另外,如果您为DidSelectRowAtIndexPath编写了代码,请检查是否有拼写错误。
我们能看到您的DidSelectRowAtIndexPath
代码吗?