2011-06-03 26 views
0

ABPersonViewController未在可編輯模式下打開。當我使用中斷點時,控件沒有到達委託方法。哪裏有問題?以下是我的代碼:ABPersonViewController未在可編輯模式下打開

 

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 

    // Fetch the address book 
    if ((people != nil) && [people count]) 

    { ABAddressBookRef addressBook = ABAddressBookCreate(); 
     //ABPersonViewController *personController = [[ABPersonViewController alloc] initWithNibName:@"ABPersonViewController" bundle:nil]; 

     ABRecordRef person = (ABRecordRef)[people objectAtIndex:indexPath.row];  
     ABPersonViewController *personController = [[[ABPersonViewController alloc] init]autorelease]; 

     personController.addressBook = addressBook; 
     personController.personViewDelegate = self; 
     personController.displayedPerson = person; 
     personController.allowsEditing = YES;  
     //navigationController = [[UINavigationController alloc] init] ; 
     [self presentModalViewController:personController animated:YES]; 
     //[self.navigationController pushViewController:personController animated:YES]; 
     //[personController release]; 
    } 
    else 
    { 
     // Show an alert if "KETAN" is not in Contacts 
     UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" 
                 message:@"Could not find naina in the Contacts application" 
                 delegate:nil 
               cancelButtonTitle:@"Cancel" 
               otherButtonTitles:nil]; 
     [alert show]; 
     [alert release]; 
    } 
    [people release]; 

} 



- (BOOL)personViewController:(ABPersonViewController *)personViewController shouldPerformDefaultActionForPerson:(ABRecordRef)person 
        property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifierForValue 
{ 
    return NO; 
} 

回答

0

您對可編輯模式的正確軌道。但是,您首先需要從導航控制器中推ABPersonViewController(請參閱documentation

相關問題