PDA

View Full Version : modal view with toolbar




MrFusion
Sep 25, 2011, 09:40 AM
I am working on my first real iPhone app. This app has a bookmark menu item in a toolbar, just like in safari. Hitting the bookmarks menu in safari presents a modal view, which slides up from under the toolbar. The items on the toolbar themselves are replaced by a "Edit" item. The navigation bar (with a "done" button) slides up with the new view.

I am trying to replicate this behavior.
This starts by creating a new UIViewController, and then displaying it.

BookmarksViewController *bookmarksViewControl = [[BookmarksViewController alloc] initWithNibName:nil bundle:nil];


First attempt to present view modally:

[[self navigationController] pushViewController:bookmarksViewControl
animated:YES];

The view slides in from the side.

Second attempt:

[[self navigationController] presentModalViewController:bookmarksViewControl animated:YES];

The bookmarksview slides in from the bottom, but covers the toolbar while doing so. When it reaches the top, the toolbar added in IB to the bookmarksview becomes visible.

Third attempt: with an intermediate UINavigationController

UINavigationController* theNavController = [[UINavigationController alloc] initWithRootViewController:bookmarksViewControl];
[theNavController setToolbarHidden:NO];
[[self navigationController] presentModalViewController:theNavController
animated:YES];


Same outcome as in attempt 2.

Fourth attempt:

[[[self navigationController] view] addSubview:[bookmarksViewControl view]];

This just shows the view, and incorrectly positioned as well. The latter can probably be fixed via the frame of the view.

Thanks for reading.
All suggestions on how to replicate Safari's behavior are welcome.