如何引用在didSelectRowAtIndexPath内单击的单元格对象:(NSIndexPath *)indexPath方法?UITableViewController didSelectRowAtIndexPath:(NSIndexPath *)indexPath
我有一个UISplitViewController,在MasterView中我有一个表,其中cell.tag = sqlite数据库的主键(即从db填充表)。我能够捕获上述方法中的点击事件,但我看不到我如何传递单元格对象,或者我可以如何引用它以获取cell.tag。最终,目标是通过主/细节委托将该ID传递给详细视图,然后根据来自主人的ID将数据加载到DetailView中。
任何提示,感激!
编辑:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell.
cell.textLabel.text = NSLocalizedString(@"Detail", @"Detail");
Entry *entry = [self.entries objectAtIndex:[indexPath row]];
[[cell textLabel] setText:[NSString stringWithFormat:@"%@",entry.title]];
cell.tag = entry.entryID;
return cell;
}
是的,这更好。我认为我必须通过我再次查询数据库,但如果我可以通过整个入口对象,这是最好的情况。谢谢! – David