이 상황을 올바르게 설명 할 수 있기를 바랍니다. 그것은 일어날 때 화면에 쉽게 볼 수 있지만 말로 설명하기는 어렵지만 최선을 다할 것입니다.UISplitViewController 세부 정보보기가 회전 할 때 크기 조정되지 않음
고정 된 마스터보기 (UITableView)가있는 UISplitViewController와 마스터에서 어떤 종류의 셀을 터치했는지에 따라 두 개의 상세보기 중 하나가 있습니다. 각 상세보기는 또한 UITableView입니다. 필자는 Apple의 MultipleDetailViews 샘플을 Todd Bates로 변환하여 스토리 보드를 코드 (Adventures in UISplitViewController)의 기반으로 사용했습니다.
저는 스토리 보드를 사용하고 있습니다. 따라서 설명 부분이 까다로워집니다. 마스터와 첫 번째로 표시된 상세보기 탐색 컨트롤러는 스토리 보드에서 UISplitViewController와의 관계로 연결됩니다. 두 번째 Detail Navigation Controller는 연결이없는 스토리 보드에 앉아 있습니다.
여기에 문제가 있습니다. 상세 정보 # 1은 가로 모드에서 활성화되고 세부 정보 # 2는 마스터의 행을 탭하여 활성으로 설정됩니다. iPad가 Portrait 모드로 회전하면 Detail # 2가 세로 모드에서 올바르게 크기 조정됩니다. 세부 정보 # 1은 마스터의 행을 탭하여 활성으로 설정됩니다. 상세 정보 # 1은 가로 모드에서 마지막으로 표시되었을 때와 동일한 크기이며 화면처럼 채워지지 않습니다.
내 질문은 오리엔테이션이 변경되었을 때 현재 크기 조정이 표시되지 않은 Detail 컨트롤러에게 말할 수 있습니까? 아니면 더 나은 질문은 UISplitView의 Detail 부분을 채우는 데 방금 표시된 Detail 뷰의 크기를 조정할 수 있습니까?
나는 이것을 누군가에게 도움이 될 정도로 자세하게 기술했으면 좋겠다.
UISplitViewControllerDelegate 메소드는 해당 호출을 Detail보기 컨트롤러로 전달해야하는 Manager 클래스에서 구현됩니다.
#pragma mark - UISplitViewControllerDelegate
/* forward the message to the current detail view
* all detail views must implement UISplitViewControllerDelegate
*/
-(void)splitViewController:(UISplitViewController *)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)pc
{
self.masterBarButtonItem = barButtonItem;
self.masterPopoverController = pc;
barButtonItem.title = NSLocalizedString(@"Games", @"Games");
[self.currentDetailController.navigationItem setLeftBarButtonItem:self.masterBarButtonItem animated:YES];
}
/* forward the message to the current detail view
* all detail views must implement UISplitViewControllerDelegate
*/
-(void)splitViewController:(UISplitViewController *)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem
{
self.masterBarButtonItem = nil;
self.masterPopoverController = nil;
[self.currentDetailController.navigationItem setLeftBarButtonItem:nil animated:YES];
}
그리고 나는 상세보기 컨트롤러 각각에 다음을 구현 : 여기에 그 방법에 대한 구현입니다
#pragma mark - Split view
- (void)splitViewController:(UISplitViewController *)splitController willHideViewController:(UIViewController *)viewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)popoverController
{
barButtonItem.title = NSLocalizedString(@"Games", @"Games");
[self.navigationItem setLeftBarButtonItem:barButtonItem animated:YES];
self.masterPopoverController = popoverController;
}
- (void)splitViewController:(UISplitViewController *)splitController willShowViewController:(UIViewController *)viewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem
{
// Called when the view is shown again in the split view, invalidating the button and popover controller.
[self.navigationItem setLeftBarButtonItem:nil animated:YES];
self.masterPopoverController = nil;
}
문제는 자세히보기 컨트롤러 중 어느 것도 이러한 메시지를 받고 있다는 것입니다. 어쨌든 그들이 어떻게 트리거되는지를 알 수는 없습니다 ...
didRotateFromInterfaceOrientation을 전달하는 방법이 표시되지 않습니다. 표시되지 않는 Detail 컨트롤러가 자체 크기를 조정하지 않습니다. 애플의 문서에서 :
아이폰 OS 기반 장치의 변화의 방향, 시스템은 모든 이해 당사자가 변화가 발생했음을 알게하는 UIDeviceOrientationDidChangeNotification 알림을 보냅니다. 기본적으로 UIKit 프레임 워크는이 알림을 가로 채고이를 사용하여 인터페이스 방향을 자동으로 업데이트합니다. 즉, 몇 가지 예외를 제외하고는이 알림을 전혀 처리 할 필요가 없습니다. 대신 방향 변경에 응답하기 위해 View Controller 클래스에 적절한 메소드를 구현하면됩니다.
window 객체는 현재 방향 변경과 관련된 많은 작업을 수행합니다. 그러나 루트 뷰 컨트롤러와 함께 작동하여 방향 변경이 발생해야하는지 여부를 결정하고, 그렇다면 변경에 응답하기 위해 추가 메서드를 호출해야합니다. 이 콘트롤러가 콘테이너라면, 오리엔테이션이 일어날지를 결정하기 위해 아이에게 의존 할 수있다.
회전이 발생하면보기 컨트롤러가 추가 작업을 수행 할 수있는 기회를주기 위해 회전의 여러 단계에서보기 컨트롤러의 메서드가 호출됩니다. 이 방법을 사용하여보기를 숨기거나 표시하고,보기의 위치를 변경하거나 크기를 조정하거나, 방향 변경에 대해 앱의 다른 부분에 알릴 수 있습니다. 회전 작업 중에 사용자 지정 메서드가 호출되므로 시간이 많이 소요되는 작업을 수행하지 않아야합니다. 또한 전체 뷰 계층 구조를 새로운 뷰 세트로 바꾸지 마십시오. 새 뷰 컨트롤러를 제공하는 것과 같이 다른 방향에 대해 고유 한 뷰를 제공하는 더 좋은 방법이 있습니다 ("대체 조경 인터페이스 만들기"에서 설명).
보이지 않으며 상세 뷰 컨트롤러- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { [super didRotateFromInterfaceOrientation:fromInterfaceOrientation]; // Forward to detail view controller here: }
(즉 NOT self.currentDetailController하지만, 다른 하나) 다음 splitViewController 방법과 유사
나는 답변을 주셨습니다. 나는 이것을 작동 시키려고 노력할 것이고, 그것이 작동한다면, 나는 그것을 대답으로 표시 할 것이다. 감사! – Moebius
감사합니다. 문제가 발생하면 가지고있는 코드를 게시하면 기꺼이 도와 드리겠습니다. – lnafziger
각 디테일 뷰 컨트롤러에서 UISplitViewControllerDelegate를 구현 한 것으로 생각되면서 코드를 살펴 보았습니다. 나는 앞서 가서 이것을했지만 Detail 뷰의 프로토콜 메서드는 호출되지 않습니다. 모든 코드를 게시 할 수는 없지만 대리자 메서드도 구현하는 Detail Manager 클래스가 있습니다. 원래 메시지에 게시하겠습니다. – Moebius