2013-06-17 1 views
1

내 앱에 연락처 선택 도구를 추가하고 있지만 검색 기능을 원하지 않습니다.연락처 선택 도구에서 검색 창 숨기기/제거 방법

연락처 선택기 (ABPeoplePickerNavigationController)에서 검색 창을 숨기거나 제거하는 방법은 무엇입니까? 상기 방법

+0

접촉 선택기? 일부 맞춤 라이브러리입니까? 그렇다면 어느 것입니까 –

+0

http://stackoverflow.com/questions/16815238/abpeoplepickernavigationcontroller-display-all-contact-data-in-a-single-cel/16815609#16815609 – Rajneesh071

답변

2
static BOOL foundSearchBar = NO; 
- (void)findSearchBar:(UIView*)parent mark:(NSString*)mark { 

    for(UIView* v in [parent subviews]) { 

     //if(foundSearchBar) return; 

     NSLog(@"%@%@",mark,NSStringFromClass([v class])); 

     if([v isKindOfClass:[UISearchBar class]]) { 
      [(UISearchBar*)v setTintColor:[UIColor blackColor]]; 
      v.hidden=YES; 
//   foundSearchBar = YES; 
      break; 
     } 
     if([v isKindOfClass:[UITableView class]]) { 
      CGRect temp =v.frame; 
      temp.origin.y=temp.origin.y-44; 
      temp.size.height=temp.size.height+44; 
      v.frame=temp; 
      //foundSearchBar = YES; 
      break; 
     } 
     [self findSearchBar:v mark:[mark stringByAppendingString:@"> "]]; 
    } 
} 

호출 선택기 후에 아래와 같이 제시된다 :

-(void)showPeoplePickerController 
{ 
    ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init]; 
    picker.peoplePickerDelegate = self; 
    picker.view.autoresizingMask = UIViewAutoresizingFlexibleHeight; 
    // Display only a person's phone, email, and birthdate 
    NSArray *displayedItems = [NSArray arrayWithObjects:[NSNumber numberWithInt:kABPersonPhoneProperty], 
           [NSNumber numberWithInt:kABPersonEmailProperty], 
           [NSNumber numberWithInt:kABPersonBirthdayProperty],[NSNumber numberWithInt:kABPersonAddressProperty],nil]; 

    picker.displayedProperties = displayedItems; 
    // Show the picker 
    [self presentViewController:picker animated:YES completion:nil]; 
    [self findSearchBar:[picker view] mark:@"> "]; 

    [picker release]; 
} 
+0

이것은 작동하지만, 하지만 오른쪽에있는 AZ는 A와 B를 자르고 C에서 시작합니다. 다음에 피커를로드하면 검색 창이 다시 나타납니다. –

+0

네, 그걸 관찰하지 못했습니다. 확인 .. – Nookaraju

+0

나는 당신의 코드를 편집했습니다 :) –

0
-(void)showAddressBook { 
    ABPeoplePickerNavigationController *addressBook = [[ABPeoplePickerNavigationController alloc] init]; 
    [addressBook setPeoplePickerDelegate:self]; 
    addressBook.delegate = self; 
    addressBook.navigationBar.topItem.title = @"iPhone Contacts"; 
    UIView *view = addressBook.topViewController.view; 
    for (UIView *v in view.subviews) { 
     if ([v isKindOfClass:[UITableView class]]) { 
      CGRect temp = v.frame; 
      temp.origin.y = temp.origin.y - 44; 
      temp.size.height = temp.size.height + 44; 
      v.frame = temp; 
     } 
    } 
    [addressBook release]; 
} 

- (void)navigationController:(UINavigationController*)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated { 
    if ([navigationController isKindOfClass:[ABPeoplePickerNavigationController class]]) { 
     UISearchDisplayController *searchDisplayController = navigationController.topViewController.searchDisplayController; 
     [searchDisplayController.searchBar setHidden:YES]; 
    } 
}