![](/img/trans.png)
[英]In ios7 tableView:didSelectRowAtIndexPath: is not called
[英]Custom TableView and using didSelectRowAtIndexPath in iOS
我通過遵循此自定義UITableViewCell創建了一個自定義TableView
我撕裂了CustomerCell,然后在ViewController中像這樣使用它:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *uniqueIdentifier = @"cutomerCell";
CustomerCell *cell = nil;
cell = (CustomerCell *) [self.tableview dequeueReusableCellWithIdentifier:uniqueIdentifier];
Customer *customer = [self.customers objectAtIndex:[indexPath row]];
if(!cell)
{
NSArray *topLevelObject = [[NSBundle mainBundle] loadNibNamed:@"CustomerCell" owner:nil options:nil];
for(id currentObject in topLevelObject)
{
if([currentObject isKindOfClass:[CustomerCell class]])
{
cell = (CustomerCell *) currentObject;
break;
}
}
}
cell.nameLabel.text = customer.name;
return cell;
}
一切正常。 但是然后我開始下一個鏈接UINavigationController
問題是當我使用此方法時:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@ "hi");
}
當我單擊TableView中的項目時,什么也沒有發生。 可能是因為我實現了Custom TableView
,然后無法使用didSelectRowAtIndexPath
方法,但是如何解決呢?
您得到的錯誤與您的筆尖而不是您的UITableView有關。 您應該檢查“客戶詳細信息”類的視圖是否已與筆尖中的其所有者連接。 這就是為什么一旦您嘗試使用它就會崩潰
[self.navigationController pushViewController:self.customerDetail animated:YES];
您設置了代表嗎? tableView.delegate =自我; 我猜你應該沒事。
對表視圖進行子類化應該不會引起這樣的問題-顧名思義,子類所做的一切都比其超類多。 似乎您只設置了數據源,但設置了委托:
tableView.delegate = self;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.