根据用户在tableview中点击(触摸)cell的自定义accessoryButton获得其indexpath
2015-08-18 10:15
465 查看
[button addTarget:self action:@selector(checkButtonTapped:event:) forControlEvents:UIControlEventTouchUpInside];
cell.accessoryView = button;
[java]
view plaincopy
<pre name="code" class="java"></pre><pre name="code" class="java">//转到显示contact详情页面
- (void)showContact:(tb_Contacts *)contacts animated:(BOOL)animated {
// Create a detail view controller, set the Contact, then push it.
EditContactViewController *editContactViewController = nil;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
editContactViewController = [[EditContactViewController alloc] initWithNibName:@"EditContactViewController_Ipad" bundle:nil];
}
else
{
editContactViewController = [[EditContactViewController alloc] initWithNibName:@"EditContactViewController" bundle:nil];
}
editContactViewController.contacts = contacts;
editContactViewController.managedObjectContext = self.managedObjectContext;
editContactViewController.hidesBottomBarWhenPushed=YES;
[self.navigationController pushViewController:editContactViewController animated:animated];
[editContactViewController release];
}
//点击详情按钮后走的方法
- (void)checkButtonTapped:(id)sender event:(id)event
{
NSSet *touches = [event allTouches];
UITouch *touch = [touches anyObject];
CGPoint currentTouchPosition = [touch locationInView:self.contactsTableView];
NSIndexPath *indexPath = [self.contactsTableView indexPathForRowAtPoint: currentTouchPosition];
if (indexPath != nil)
{
[self tableView: self.contactsTableView accessoryButtonTappedForRowWithIndexPath: indexPath];
}
}</pre><pre name="code" class="java">//选中需要显示contact详情的行走的方法
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
{
tb_Contacts *contacts = (tb_Contacts *)[fetchedResultsController objectAtIndexPath:indexPath];
[self showContact:contacts animated:YES];
}
cell.accessoryView = button;
[java]
view plaincopy
<pre name="code" class="java"></pre><pre name="code" class="java">//转到显示contact详情页面
- (void)showContact:(tb_Contacts *)contacts animated:(BOOL)animated {
// Create a detail view controller, set the Contact, then push it.
EditContactViewController *editContactViewController = nil;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
editContactViewController = [[EditContactViewController alloc] initWithNibName:@"EditContactViewController_Ipad" bundle:nil];
}
else
{
editContactViewController = [[EditContactViewController alloc] initWithNibName:@"EditContactViewController" bundle:nil];
}
editContactViewController.contacts = contacts;
editContactViewController.managedObjectContext = self.managedObjectContext;
editContactViewController.hidesBottomBarWhenPushed=YES;
[self.navigationController pushViewController:editContactViewController animated:animated];
[editContactViewController release];
}
//点击详情按钮后走的方法
- (void)checkButtonTapped:(id)sender event:(id)event
{
NSSet *touches = [event allTouches];
UITouch *touch = [touches anyObject];
CGPoint currentTouchPosition = [touch locationInView:self.contactsTableView];
NSIndexPath *indexPath = [self.contactsTableView indexPathForRowAtPoint: currentTouchPosition];
if (indexPath != nil)
{
[self tableView: self.contactsTableView accessoryButtonTappedForRowWithIndexPath: indexPath];
}
}</pre><pre name="code" class="java">//选中需要显示contact详情的行走的方法
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
{
tb_Contacts *contacts = (tb_Contacts *)[fetchedResultsController objectAtIndexPath:indexPath];
[self showContact:contacts animated:YES];
}
相关文章推荐
- 大白话系列之C#委托与事件讲解(序言)
- AHB-Lite简介
- 当当网
- 屏蔽所有统计代码(51.la cnzz 百度统计 谷歌分析师adsense、屏蔽淘宝客广告代码)的方法
- JackSon 数据之间的转换 java
- MYSQL-目录文件分配查询
- Gradle Android最新自动化编译脚本
- Oracle 分区操作
- GitHub和SourceTree入门教程
- 如何在shell中处理异常
- window server2008 R2 mvc 项目服务器环境的搭建。
- redis.conf配置详解
- Ubuntu14.04下安装OpenCV 3.0.RC1
- 苹果开发 笔记(62)edgesForExtendedLayout
- SQL_修改表结构
- Ugly Numbers(STL应用)
- iOS开发-UICollectionView
- Linux下查看目录大小
- 8月15日全球域名注册商(国际域名)保有量及市场份额
- .NET平台和Csharp编程开发学习教程