- [button addTarget:self action:@selector(checkButtonTapped:event:) forControlEvents:UIControlEventTouchUpInside];
- cell.accessoryView = button;
- <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];
- }