0
votes

I have a UISplitViewController in an iPad app. When something is selected from the table I want to fade in a modal view controller over the detail view. I can present it without a problem, but for some reason I can't get it to match the frame of the detail view. I would like it to stick to the detail view controller frame on rotation as well. Does anyone have any experience with this? This is my code to display. The detail view controller reference is set in the app delegate and passed down the table controllers.

QuestionViewController_iPad *questionView = [[[QuestionViewController_iPad alloc] initWithNibName:@"QuestionViewController_iPad" bundle:nil] autorelease];
questionView.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;

// Not quite
questionView.modalPresentationStyle = UIModalPresentationCurrentContext;
questionView.questionQuizCon = [QuestionQuizConnection firstQuestionForQuiz:quizCatCon.quiz];

// Maybe something like this?
[self.detailViewController presentModalViewController:questionView animated:YES];

When the modal view presents, it matches the size of the detail view controller, but it doesn't but it sits on the top left of the screen behind the master view controller. It also doesn't resize on rotation. I have the springs and struts set to auto size and fill. The height changes on rotation but it won't fill the width.

2
Try setting the presentationStyle to UIModalPresentationPageSheet and see what happens there.user244343
That just shows up in the middle of the page on top of everything.codeetcetera

2 Answers

0
votes

I couldn't get this to look right any way I tried it so I ended up just using view transitions to make it look like pages being torn off a notebook. That looks better anyway.

// Transition the view on as a subview.
[UIView transitionWithView:self.detailViewController.pageView duration:1.0
                   options:UIViewAnimationOptionTransitionCurlUp
                animations:^ { 
                    questionView.view.frame = CGRectMake(0, 0, self.detailViewController.pageView.frame.size.width, self.detailViewController.pageView.frame.size.height); 
                    [self.detailViewController.pageView addSubview:questionView.view]; 

                    // Watch this one
                    self.detailViewController.currentQuestionViewController = questionView;
                }
                completion:nil];
-1
votes

After [self.detailViewController presentModalViewController:questionView animated:YES]; you should set center property and/or frame of questionView. Be sure that you set it after presenting modal view.