Note that there are some explanatory texts on larger screens.

plurals
  1. POiphone: partial-screen UIScrollView
    text
    copied!<p>I'm a long-time web guy who's pretty new to iphone development. I'm finding many problems I run into stem from thinking about things in terms of web pages, so it's very possible I'm just not asking the right questions on this one. Nonetheless, after a few hours pouring over google results and stackoverflow pages, time to throw this question out into the void:</p> <p>I'm trying to set up a view that has some static/un-moving stuff at the very top (for example, the title of the content shown below), and allow the rest of the "page" to scroll.</p> <p>My thought process as it stands now is to create a view that holds the static portion, and a blank space, and then somehow add a scrollview to that blank space, but this is where my knowledge is running dry.</p> <p>Code-wise, it's looking something like this (i've added comments to show my thought process on using this code):</p> <p>DetailsWrapper.m:</p> <pre><code>-(void)viewDidLoad { //initialize details view (custom constructor that populates some stuff) //ListingDetails is a subclass of UIViewController whose view is set to be a UIScrollView created in IB //the viewDidLoad method of ListingDetails sets the contentSize of the scroll view ListingDetails *details = [[ListingDetails alloc] initWithNibName:@"ListingDetails" andListingData:theListing]; //create an empty view that takes up all but the top 45px of the iphone screen CGRect scrollArea = CGRectMake(0.0f, 45.0f, 320.0f, 435.0f); UIView *scrollView = [[UIView alloc] initWithFrame:scrollArea]; //add the UIScrollView to the space we just made [scrollView addSubview:details.view]; //now show it [self.view addSubview:scrollView]; //cleanup [scrollView release]; [details release]; } </code></pre> <p>That all works fine and dandy, and pulls in the content correctly, with the minor problem that the scroll view doesn't actually...scroll. If I try to add the ListingDetails view normally, without using this wrapper, the scrolling works just fine, but something I'm doing (or not doing?) above is making the scroll functionality cease to be.</p> <p>Am I thinking about this all wrong? Ultimate goal is to get a screen where part of it scrolls and part does not, so if it helps to ignore all my rambling above and just address that, go for it.</p>
 

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