내 상태를 응용 프로그램에 통합하려고합니다. 나는 대부분 잘 작동하지만, 다른 네비게이션 컨트롤러 위에 모달 뷰를위한 네비게이션 컨트롤러를 제시하는 것은 어려운 일이다.iOS 상태 복원 및 UINavigationController 모달보기
테스트를 위해 iPad에서 분할보기 양쪽에 탐색 컨트롤러가있는 새 분할보기 응용 프로그램을 만들고 각각의 탐색 컨트롤러의 뿌리 인 양쪽에 대한 마스터 및 세부보기 컨트롤러를 만들었습니다. 마스터 뷰에서 버튼을 클릭하여 새로운 TestViewController를 navController 스택에 프로그래밍 방식으로 푸시 (push) 할 수 있습니다. 스토리 보드에서 splitView를 연결하고, 모든 것에 restorationID를 추가하고, 델리게이트에 옵트 인하고, 복원 클래스를 제공하고, TestViewController의 UIViewControllerRestoration 프로토콜을 준수합니다 (프로그래밍 방식으로 생성되기 때문에). 모든 것이 잘 작동합니다. 앱을 닫고 레토르트하면 마스터의 navcontroller에 푸시 된 TestViewController가 시작됩니다. 여태까지는 그런대로 잘됐다.
그런 다음 단추 탐색기를 변경하여 TestViewController를 새 UINavigationController 내에 표시하고 마스터의 탐색 컨트롤러에 표시하여 모달보기를 표시합니다 (nav 스택에 푸시하는 대신). 이제 앱을 다시 시작하면 더 이상 모달보기가 없습니다. TestModalViewController의 viewControllerWithRestorationIdentifierPath : 코더 : 실제로 이전처럼 올바르게 호출되지만 모달 뷰는 어떤 이유로 든 표시되지 않습니다.이
- (void)pushButton:(id)sender
{
TestModalViewController *test = [[TestModalViewController alloc] initWithNibName:@"TestViewController" bundle:nil];
test.restorationIdentifier = @"testid";
test.restorationClass = [TestModalViewController class];
UINavigationController *modal = [[UINavigationController alloc] initWithRootViewController:test];
modal.modalPresentationStyle = UIModalPresentationFormSheet;
modal.restorationIdentifier = @"ModalTestID";
[self.navigationController presentViewController:modal animated:YES completion:nil];
return;
}
TestModalViewController.m :
+ (UIViewController *) viewControllerWithRestorationIdentifierPath:(NSArray *)identifierComponents coder:(NSCoder *)coder {
TestModalViewController *test = [[TestModalViewController alloc] initWithNibName:@"TestViewController" bundle:nil];
test.restorationClass = [TestModalViewController class];
test.restorationIdentifier = [identifierComponents lastObject];
return test;
}
아마도 UINavigationController가가 여기에
내가 약MasterViewController.h을 무슨 말인지 코드입니다 모달로 표시되도록 생성 된 내용이 보존되지 않습니까? 왜 RestorationIdentifier가 없기 때문에 이유를 모르겠습니다.
편집 : 코드, 직접, 제대로 복원 가져옵니다 TestModalViewController 인스턴스를 제시 : 나는 푸시 버튼에서 UINavigationController가를 제거하는 경우
추가 시험 후에는 밝혀졌습니다. 그래서 뭔가 다른 UINavigationController에서 제시되는 UINavigationController에 대해?
(정말 원하지 무엇을하지만)이 작동 :
- (void)pushButton:(id)sender
{
TestModalViewController *test = [[TestModalViewController alloc] initWithNibName:@"TestViewController" bundle:nil];
test.restorationIdentifier = @"testid";
test.restorationClass = [TestModalViewController class];
//UINavigationController *modal = [[UINavigationController alloc] initWithRootViewController:test];
//modal.modalPresentationStyle = UIModalPresentationFormSheet;
//modal.restorationIdentifier = @"ModalTestID";
[self.navigationController presentViewController:test animated:YES completion:nil];
return;
}
편집 : 테스트 프로젝트에 첨부 링크 : 그것은 기본적으로 코어 데이터 마스터 - 세부 템플릿의 dropbox.com/sh/w8herpy2djjl1kw/vw_ZWqimgt
을; iPad 시뮬레이터에서 실행하십시오. 마스터의 + 버튼은 TestModalVC를 호출합니다. 그런 다음 홈 버튼을 누른 다음 디버거를 종료하고 다시 시작하면 스냅 샷에 TestModalVC가 포함되어 있지만 응용 프로그램이 시작되면 복원되지 않습니다.
샘플 프로젝트를 첨부 할 수 있습니까? –
여기 링크가 있습니다 : https://www.dropbox.com/sh/w8herpy2djjl1kw/vw_ZWqimgt –