Man*_*lio 6 cocoa-touch objective-c uitableview uikit ios
我用的UITableViewCellAccessoryDisclosureIndicator是accessoryType 我的UITableViewCell.根据Apple的文档,数据源方法
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
Run Code Online (Sandbox Code Playgroud)
应该自动被调用.
如果单元格已启用且附件类型为UITableViewCellAccessoryDetailDisclosureButton,则附件视图将跟踪触摸,并在轻触时向数据源对象发送tableView:accessoryButtonTappedForRowWithIndexPath:消息.
这是我的代码:
- (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];
}
[cell.textLabel setText:[datasource objectAtIndex:indexPath.row]];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
Run Code Online (Sandbox Code Playgroud)
数据源方法只是一个NSLog但没有打印出来......
我错过了什么吗?(当然,数据源和委托设置正确)
Mar*_*off 17
答案就在你的问题中.你说
我使用UITableViewCellAccessoryDisclosureIndicator作为accessoryType ...
并且你部分引用了Apple文档
如果单元格已启用且附件类型为UITableViewCellAccessoryDetailDisclosureButton ...
只有在使用时才会UITableViewCellAccessoryDetailDisclosureButton调用委托方法.当然,区别在于这是一个按钮,而UITableViewCellAccesssoryDisclosureIndicator不是.当你使用后者时,点击它就像敲击细胞本身一样.您可以创建一个自定义单元格并实现hitTest:以确定点击是否"接近"披露指示器,但这似乎比必要的工作更多(除非您真的不想使用详细信息披露按钮).
| 归档时间: |
|
| 查看次数: |
4669 次 |
| 最近记录: |