abpeoplepickernavigationcontroller- 개인 메소드/속성을 사용하지 않고 "취소"버튼을 제거합니까?

StackOverflow https://stackoverflow.com/questions/1611499

문제

UinaVigationController의 서브 클래스 인 AbpeoplePickerNavigationController를 사용하고 있으며 컨텍스트에서 오른쪽의 기본 NAV 막대 버튼 인 "CANCEL"은 의미가 없습니다. 나는 그것을 비활성화하거나 숨길 수있는 방법을 찾을 수 없으며, 사용 된 방법은 공개 및 상점 승인 가능해야합니다. Nav Bar를 완전히 제거하면 (Picker.NavigationBarhidden = Yes;) NAV BAR이 다시 나타나는 연락처 목록으로 다시 팝업 한 후에는 옵션이 될 수 있습니다. 서브 클래스 abpeoplepickernavigationcontroller 및 viewwillAppear를 가로 채기 위해 취소 버튼이 작동하지 않았습니다. [피커 setAllowsCancel : 아니요]; 작동하지만 문서화되지 않으므로 승인을받지 않을 것으로 기대합니다.

도움이 되었습니까?

해결책 3

이에 대한 답이 없습니다. 취소로 살 수 없다면 새로운 사람 피커를 작성하십시오.

다른 팁

이 하나

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
  UIView *custom = [[UIView alloc] initWithFrame:CGRectMake(0.0f,0.0f,0.0f,0.0f)]; 
  UIBarButtonItem *btn = [[UIBarButtonItem alloc] initWithCustomView:custom]; 
  //UIBarButtonItem *btn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addAction)]; 
  [viewController.navigationItem setRightBarButtonItem:btn animated:NO]; 
  [btn release]; 
  [custom release]; 
}

완벽하게 작동합니다!

Delegate Method NavigationController : WillshowViewController : Animated : Do Work를 사용하는 예제의 예제는 자신의 컨트롤러에 자신의 탐색 항목을 추가하려는 경우가 될 수 있으며 주어진 옵션은 자신의 컨트롤러에서 설정할 수있는 모든 것을 제거합니다. . 이 옵션이 잘 작동하기 위해 성공적으로 사용한 코드는 다음과 같습니다.

- (void)navigationController:(UINavigationController *)navigationController
      willShowViewController:(UIViewController *)viewController
                    animated:(BOOL)animated {

    // Here we want to remove the 'Cancel' button, but only if we're showing
    // either of the ABPeoplePickerNavigationController's top two controllers
    if ([navigationController.viewControllers indexOfObject:viewController] <= 1) {

        viewController.navigationItem.rightBarButtonItem = nil;
    }
}

내비게이션 컨트롤러 스택에는 두 개의 뷰 컨트롤러, 연락처 그룹 및 연락처 목록 용 컨트롤러가 있습니다. 이것이 바로 FI를 확인할 수없는 이유입니다. ViewController는 탐색 컨트롤러의 상단 뷰 컨트롤러입니다.

피커 하위 뷰를 통해 해당 결과 브라우징을 달성 할 수 있습니다. 조금 지루한 ...

아직 시도하지는 않았지만 UBY는 iskindofclass : [uibarbuttonitem 클래스]를 찾을 때까지 피커의 하위 뷰를 반복한다고 말하면 타이틀 속성을 변경할 수 있습니다. NavigationBar의 '항목'배열에도있을 수도 있습니다.

PeoplePickerController 컨트롤러로 대의원을 설정하십시오. 대의원 수업 에서이 대표 방법이 있습니다.

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
 UIView *pCustomView = [[UIView alloc] initWithFrame:CGRectMake(0,0,0,0)];
 UIBarButtonItem *pBtn = [[UIBarButtonItem alloc] initWithCustomView:pCustomView];
 [viewController.navigationItem setRightBarButtonItem:pBtn animated:NO];
 [pBtn release];
 [pCustomView release];
}

다음 방법을 구현하는 클래스에 Picker Object (PeoplePickerDelegate가 아닌 Delegate가 아닌) 대의원을 설정하십시오.

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
UIView *custom = [[UIView alloc] initWithFrame:CGRectMake(0,0,0,0)];
UIBarButtonItem *btn = [[UIBarButtonItem alloc] initWithCustomView:custom];
[viewController.navigationItem setRightBarButtonItem:btn animated:NO];
[btn release];
[custom release];
} 

잘 작동하지만 iOS 4에는 하나 더 있습니다. 빠른 앱 전환 기능을 사용하여 앱으로 다시 전환하면 취소 버튼이 다시 나타납니다.

방법

- (void)navigationController:(UINavigationController *)navigationController  
      willShowViewController:(UIViewController *)viewController
                    animated:(BOOL)animated

호출되지 않습니다. 그래서 나는 이것을 만들었다 :

- (void)applicationDidEnterBackground:(UIApplication *)application {
    id topView = pickerControllerDelegate.peoplePicker.topViewController;
    topView.navigationItem.rightBarButtonItem = nil;
}

그것은 꽤 잘 작동합니다.

Russel B에 따르면 당신은 당신을 덮어 쓸 수 있습니다 ViewDidapper

이것은 나를 위해 효과가있었습니다.

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    UINavigationItem *item = (UINavigationItem *)[self.navigationBar.items lastObject];
    item.rightBarButtonItems = [[NSArray alloc] init];

    item.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addPerson)];
}

편집 : 아래 주석을 참조하십시오. 이것은 이제하지 말아야 할 일의 예입니다.

AbpeoplePickerNavigationController를 서브 클래싱하고 현재 탐색보기 컨트롤러보기를 변경하는 모든 이벤트를 가로 채서 공개 API와 함께 원하는 동작을 얻으려고 노력했습니다. 그런 다음 뷰 계층 구조를 탐색하고 원치 않는 버튼을 모두 제거 할 수 있습니다.

대의원에서 View Hierarchy를 탐색 할 수는 있지만, 뷰 상태를 변경하는 이벤트에 특권이 없습니다.

이 코드 거의 저를 위해 일했습니다 (참고 : 그것은 무차별적인 버튼을 모두 죽입니다) :

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    [self killCancelButton];
}

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
    [super pushViewController:viewController animated:animated];
    [self killCancelButton];
}

- (UIViewController*)popViewControllerAnimated:(BOOL)animated {
    UIViewController *result = [super popViewControllerAnimated:animated];
    [self killCancelButton];
    return result;
}

- (void)killCancelButton {
    for (NSUInteger itemIdx = 0; itemIdx < self.navigationBar.items.count; itemIdx++) {
        UINavigationItem *item = [self.navigationBar.items objectAtIndex:itemIdx];
        item.rightBarButtonItems = [[NSArray alloc] init];
    }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top