Note that there are some explanatory texts on larger screens.

plurals
  1. POpresentModalViewController slides a new view too far up and goes above the top of the screen
    text
    copied!<pre><code>-(void)reviewClicked:(id)sender { ReviewViewController *newView = [[ReviewViewController alloc] init]; newView.delegate = self; UINavigationController *navCon = [[UINavigationController alloc] initWithRootViewController:newView]; [self presentModalViewController:navCon animated:YES]; } </code></pre> <p>I have a splitViewController setup, which is what is probably causing some issues. Within the detail view controller, I have a button that when clicked calls the above code. </p> <p>The goal is to slide a view from the bottom of the screen upwards so the user can review their selections, and then click a button to return back to the original detail view. This code is working and you can click back and forth between the modal view and original detail view.</p> <p>The problem is, after it slides up the screen, it continues sliding past where it should stop, and finally stops a good 10-15 pixels too far up. Basically, this modal view slides in so far up that a good chunk of the view goes above the top of the screen. Meanwhile, that same amount of space is "empty black space" at the bottom of the screen, just further suggesting that the view just simply moved too far up.</p> <p>Complicating matters, it slides in just fine in landscape mode.</p> <p>So the question is, does anyone know why this bug is occurring to make the modal view slide too far up and past the top of the screen?</p> <p>-=-=-=-=-=-=-</p> <p>Edit: Sorry about that, I meant to type navCon in that spot. I fixed it above.</p> <p>-=-=-=-=-=-=-</p> <p>Solution:</p> <pre><code>-(void)reviewClicked:(id)sender { ReviewViewController *newView = [[ReviewViewController alloc] init]; newView.delegate = self; UINavigationController *navCon = [[UINavigationController alloc] initWithRootViewController:newView]; navCon.view.frame = CGRectMake(0, 0, 768, 1080); [self presentModalViewController:navCon animated:YES]; } </code></pre> <p>After some trial and error, I realized I had never actually set the frame of the view! A solution as simple as that...I had been running through examples that included .xib files, and since those files created the frame automatically, I totally overlooked it!</p> <p>Keep in mind for anyone looking at this in the future. This frame is for portrait mode only. If you want landscape mode, just modify the frame accordingly:</p> <pre><code>navCon.view.frame = CGRectMake(0, 0, 1080, 768); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload