Search code examples
iphoneuiviewuiwindow

iPhone basic sheet programming?


I want to program an "Add"-Window to my application, much like the "Add Contact"-window in the Contacts app or the "Add City"-window in the Weather app.

My question is: how do I code the effect of sliding up that Contacts & Weather feature?

-- Ry


Solution

  • These are called "modal view controllers".

    You create a view controller for that "sheet", and from any method of another view controller call

    sheetViewController = [[SheetViewController alloc] init…]
    [self presentModalViewController:sheetViewController animated:YES];
    

    to slide up the sheet, and from any method of the sheet view controller call

    [self dismissModalViewControllerAnimated:YES];
    

    to slide down. Search the term "Modal View Controllers" in the Xcode docs for detail.