나는 비슷한 문제가 있었고 "모달 체인"은 제한되지 않았습니다. 저는 답변에있는 논점과 아래에 다른 것에 대해 언급 된 모달 쎄그 (modal segues)에 대한 의견에 동의하지만, 모달 쎄그의 "수평 플립"애니메이션이 좋았고 그것들을 복제하는 더 쉬운 방법을 찾을 수 없었습니다 ... 또한 일반적으로 저는 모달 컨트롤러를 연결하는 것과 같은 다른 일을 성취하기 위해 설계된 것을 사용하는 데있어 잘못된 점을 보지 마십시오. 반복 된 "부분 컬"애니메이션은 일부 앱의 일부 시나리오에도 적용될 수 있습니다.
그래서 제어기의 속성으로 모달 컨트롤러의 스택을 구현 :
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"modalSegue"]) {
ModalViewController *controller =
(ModalViewController *)[segue destinationViewController];
controller.modalControllers = [NSMutableArray arrayWithObject: controller];
}
}
을 : 제 모달 SEGUE 모달되지 컨트롤러 prepareForSegue 방법에서 생성 된 스택을 실행
@interface ModalViewController : UIViewController
@property (nonatomic, retain) NSMutableArray *modalControllers;
@end
하나 모달 제어기는 다른 이동하면
대상이
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"modalSegue"]) {
ModalViewController *destController =
(ModalViewController *)[segue destinationViewController];
// add destination controller to stack
destController.modalControllers = _modalControllers;
[destController.modalControllers addObject: destController];
}
}
,617 (ModalViewCotroller의 방법에서) 스택에 추가
전체 스택을 한 번에 닫으려면 가장 까다로운 부분이었습니다. 다음 해고가 완료되기 전에 이전 컨트롤러를 닫을 수 없으므로 순환이 작동하지 않으며 재귀 블록 만이 메모리 누수를 피하면서 트릭을 수행했습니다. (나는 그것을 확인하기 위해 아직,하지만 난이 this에 의존) 까다로운는 :
더 탐색 컨트롤러가 없습니다
- (IBAction)dismissAllModalControllers: (id)sender
{
// recursive block that dismisses one auth controller
// all these dances are to avoid leaks with ARC
typedef void (^voidBlockType)();
__block void (^dismissController)();
voidBlockType __weak dismissCopy = ^void(void) {
dismissController();
};
dismissController = ^void(void) {
int count = [_modalControllers count];
if (count > 0) {
// get last controller
UIViewController *controller =
(UIViewController *)[_modalControllers lastObject];
// remove last controller
[_modalControllers removeLastObject];
// dismiss last controller
[controller
// the first controller in chain is dismissed with animation
dismissViewControllerAnimated: count == 1 ? YES : NO
// on completion call the block that calls this block recursively
completion: dismissCopy];
}
};
// this call dismisses all modal controllers
dismissController();
}
출처
2013-05-23 18:37:59
esp
... 그것은 두 단계 모달 SEGUE 체인으로 나타내는 탭보기 컨트롤러입니다. –
네비게이션 컨트롤러가없는 루트 뷰로 다시 "터지기"하고 있습니까? UINavigationController가 작성된 정확한 이유는 사용자가 요구하는 동작입니다. 내가 놓친 게 아니라면? –
죄송합니다.보기 컨트롤러를 제거하는 일반적인 의미에서 "팝"을 사용하고 있습니다. 루트 탐색 컨트롤러가 없습니다. 모달 섹터를 통해 앱에 "터널"인 두 개의 표준보기 컨트롤러가 있고 다른보기가 포함 된 탭보기 컨트롤러가 있습니다. 나는 대답을 알아 냈다.하지만 아래를 보라. –