PresentViewController without fullscreen

Quick question. When I use presentViewController to present a new view manager on top of my current one, it is full screen. How do I get a specific size? Or should I use a different method.

Code:

 - (IBAction)showProfile:(id)sender { ProfileView *profileTop = [[ProfileView alloc] init]; profileTop.delegate = self; [self presentViewController:profileTop animated:YES completion:nil]; } 
+6
source share
4 answers

If you are developing an application for iPad , you can use the viewController modalPresentationStyle property, you need to set viewController for the view.

It has 4 values ​​for this variable.

 UIModalPresentationFullScreen = 0, UIModalPresentationPageSheet, UIModalPresentationFormSheet, UIModalPresentationCurrentContext 

You can choose which one is best for you.

+7
source

I would suggest doing a little more research, particularly at Apple. It should be noted that this quote is provided in the View Controller Programming Guide ( http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/ModalViewControllers/ModalViewControllers.html ):

Presentation styles for modal views

In iPad apps, you can present content using several different styles. In iPhone applications, the presented views always cover the visible part of the window, but when working on the iPad, the view controllers use the value in the modalPresentationStyle property to determine their appearance when they are presented. Various parameters of this property allow you to present a view controller so that it fills all or only part of the screen.

Specifically, on the API reference page for presentViewController ( http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instm/UIViewController/presentViewController : animated: completion :):

On iPhone and iPod touch, the view is always full screen. On an iPad, presentation depends on the value in the modalPresentationStyle property.

Only the iPad seems to have support for not full-screen modals.

+6
source

On an iPad, you can simply use:

 [viewcontroller setModalPresentationStyle:UIModalPresentationFormSheet]; 

Example:

 LoginDialogViewController * login_dialog = [[LoginDialogViewController alloc] init]; [login_dialog setModalPresentationStyle:UIModalPresentationFormSheet]; [self presentViewController:login_dialog animated:true completion:nil]; 
+3
source

You can use the same code. Then adjust the size of the view in the xib file. See picture below. size inspector

0
source

Source: https://habr.com/ru/post/945592/


All Articles