简体   繁体   中英

what type of view controller is this?

and how do you create it? - the popup one in the middle

http://blogs.plos.org/mfenner/files/2011/01/IMG_0040-500x375.jpg

I would lie to use something like this for my game (in the main menu).

There is no type for UIViewController . There are different ways how you can present UIViewController .

iPad support following three type:

  1. Full Screen
  2. Page Sheet
  3. From Sheet

Your image is showing third one UIModalPresentationFormSheet .

You can Find detail of how to use this three type of presentation at following app guide: Presenting View Controllers from Other View Controllers .

That's the link to the documentation.

Presenting View Controllers from Other View Controllers

A modal view controller is a controller that can be presented on top of another one.

To create it, for example, you can just call presentViewController:animated:completion: method of the current view controller, passing in the view controller you want to present.

Since the interface you have uploaded contains a navigation bar that contains a close bar button item, you can simply wrap the controller you want to present in a navigation controller.

YourViewController *yourViewController = [[YourViewController alloc] init];

UINavigationController *navigationController = [[UINavigationController alloc]
                             initWithRootViewController:yourViewController];
[self presentViewController:navigationController animated:YES completion: nil];

Otherwise, you can create a plain controller and use a UIToolBar .

Hope that helps.

PS The close button will not be there for free. You need to add it ;)

I think it would be much better to use a third party library instead of implementing it. There are many libraries that offer similar functionality.

If you do not want to use the above libraries, you can use UIModalPresentationFormSheet explained by Apple in this document: Presenting View Controllers from Other View Controllers

Hope this helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM