2010-01-03 7 views
1

나는 ABPersonViewController를 사용하고 "정보"보기에 레이블을 추가하고 있습니다. 것은 : 내가 "편집"버튼을 클릭했을 때 : personController.allowsEditing = YES; 내보기가 "편집보기"로 이동하고 내 레이블이 여전히 있습니다 (계획 한대로가 아님) 사용자가 "편집"버튼을 눌렀을 때 "알릴 수 있는지"를 알아 내려고합니다. 그래서 제거 할 수 있습니다. 현재 뷰에서 내 레이블을 "Edity View"로 보내기 전에ABPersonViewController - "편집"버튼에서 콜백 - 목표 C

내가 생각하는 유일한 옵션은 ABPersonViewController에서 편집을 비활성화하고 "편집"버튼을 내 자신의 것으로 만드는 것입니다. 주소록 "편집"버튼의 동일한 동작을 구현하십시오 ...

"편집"버튼을 누르면 콜백 옵션이 있습니까? 여전히 ABPersonViewController의 동일한 동작을 유지합니까?

또는 어쩌면 나는 내가 "정보"보기에 아니다 때 내가 라벨을 제거 할 수 있습니다 (태그 또는 뭔가를해야만 ...?)을 ABPersonViewController에서에서 오전 볼 수있는 알 수있는 방법이

감사합니다

Itay

+0

어떤 프로그래밍/스크립팅 언어입니까? 질문을 편집하고 이에 따라 태그를 업데이트하십시오. – BalusC

+0

할 것입니다. 감사합니다. – Itay

답변

2

그냥 편집을 누를 때 알림을받을 수있는 약간 해키 찾는 방법을 알아 냈어. self.navigationItem.rightBarButtonItem을 :

-(void)viewDidAppear:(BOOL)animated{ 

    [self.navigationItem.rightBarButtonItem setTarget:self]; 
    [self.navigationItem.rightBarButtonItem setAction:@selector(editPressed)]; 

} 

내가보다 편집 버튼에 더 나은 참조를 찾을 수 없습니다 :

ABPersonViewController의 서브 클래스를 생성하고 편집 버튼을 사용자 정의 액션을 첨부 : 초기화에서보기 컨트롤러

은 다음 editPressed 조치를 만들 :

-(void)editPressed{ 

    [super setEditing:!super.editing]; 

    if(self.editing){ 

     NSLog(@"Editing"); 

     //Insert code to put your custom view in edit mode 

    }else{ 

     NSLog(@"Not editing"); 

     //Insert code to take your custom view out of edit mode 

    } 
} 

그것은 01를 호출하는 것이 중요합니다이 먼저 있으므로 UIPersonViewController은 적절하게 편집 모드로 들어가고 나오지 않습니다 (사용자 정의 액션 정의는 기본 액션을 덮어 씁니다). 또한 'self.editing'이 올바른 값을 제공하도록보기 컨트롤러의 'editing'속성을 올바르게 업데이트합니다.

+0

"완료"(righttabbarbutton)를 누르면이 솔루션으로 충돌이 발생합니다. 의견이 있으십니까? – AKG

5

또는 서브 클래스로 setEditing:animated을 재정의 할 수 있습니다. 이 설정 기는 EditDone에 대해 호출되지만 Cancel에 대해서는 호출되지 않으며 콜백이 여전히 필요합니다. 아래 예제는 레코드를 편집 할 때 툴바를 숨기고 완료되면 복원합니다.

// Override setter to show/hide toolbar 
- (void)setEditing:(BOOL)editing animated:(BOOL)animated { 
    [super setEditing:editing animated:animated]; 
    self.navigationController.toolbarHidden = editing; 
    if (editing) { 
     [self.navigationItem.leftBarButtonItem setTarget:self]; 
     [self.navigationItem.leftBarButtonItem setAction:@selector(cancel)]; 
    } 
} 

// Cancel button callback (does not invoke setEditing:animated) 
- (void)cancel { 
    [self setEditing:NO animated:YES]; 
} 
+0

Subclassing ABPersonViewController는 현재 Apple에서 허용하지 않습니다. –