【发布时间】:2016-09-09 10:35:25
【问题描述】:
我的 didSelectRowAtIndexPath 方法没有被调用。我重新加载表并重新加载并调用 talbeView
的所有方法这是我所有的tableview方法:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *s = (NSString *) [app.Glb.arrayRoomList objectAtIndex:indexPath.row];
NSString *cellIdentifire = @"CellRoomList";
CellRoomList *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifire];
if(cell == nil)
{
cell = (CellRoomList*)[[[NSBundle mainBundle] loadNibNamed:@"CellRoomList" owner:self options:nil] objectAtIndex:0];
}
cell.lblRoomName.text = s;
return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [app.Glb.arrayRoomList count];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
NSString *userName = (NSString *) [app.Glb.arrayRoomList objectAtIndex:indexPath.row];
NSLog(@"userName :---- %@",userName);
ViewController *chatController = [[ViewController alloc] init];
chatController.chatWithUser = userName;
[self.navigationController pushViewController:chatController animated:YES];
}
我在堆栈中阅读了一些问题,但无法得到答案。
如果我长时间触摸单元格而不是单元格的颜色变化但不称为didSelectRowAtIndexPath
为什么不叫它?
这里是快照:
【问题讨论】:
-
你有没有用你的viewController设置tableView委托
tableView.delegate = self; -
是的,我在 XIB 上添加了它,这就是我调用其他方法的原因
-
在 NSLog 中打印时是否可以检查用户名?
-
didSelectRowAtIndexPath 是 tableView 委托。 cellForRowAtIndexPath 和 numberOfRowsInSection tableview 数据源。所以你说两者都是连接的。与代表一起检查一次这个问题。删除一次再添加试试
-
是的,它是一样的...@Vickyexpert
标签: ios objective-c uitableview tableview