Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PresentViewController without fullscreen

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

Code:

- (IBAction)showProfile:(id)sender {
ProfileView *profileTop = [[ProfileView alloc] init];
profileTop.delegate = self;

[self presentViewController:profileTop animated:YES completion:nil];
}
like image 778
Tarayaa Avatar asked May 22 '13 13:05

Tarayaa


3 Answers

If you are developing an app for iPad then you can make use of viewController's modalPresentationStyle property, You need to set for presenting viewController.

It has 4 values for that variable.

UIModalPresentationFullScreen = 0,
UIModalPresentationPageSheet,
UIModalPresentationFormSheet,
UIModalPresentationCurrentContext

You can select which one suites you the best.

like image 132
Prasad Devadiga Avatar answered Oct 06 '22 00:10

Prasad Devadiga


I'd suggest doing a little more research, specifically in Apple's reference. Of note, there is this quote from the View Controller Programming Guide (http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/ModalViewControllers/ModalViewControllers.html):

Presentation Styles for Modal Views

For iPad apps, you can present content using several different styles. In iPhone apps, presented views always cover the visible portion of the window, but when running on an iPad, view controllers use the value in their modalPresentationStyle property to determine their appearance when presented. Different options for this property allow you to present the view controller so that it fills all or only part of the screen.

And 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 presented view is always full screen. On iPad, the presentation depends on the value in the modalPresentationStyle property.

Only the iPad appears to have any support for non-fullscreen modals.

like image 25
Jason M. Batchelor Avatar answered Oct 06 '22 00:10

Jason M. Batchelor


On iPad you can just use:

[viewcontroller setModalPresentationStyle:UIModalPresentationFormSheet];

example:

LoginDialogViewController * login_dialog = [[LoginDialogViewController alloc] init];
[login_dialog setModalPresentationStyle:UIModalPresentationFormSheet];
[self presentViewController:login_dialog animated:true completion:nil];
like image 43
Notive Avatar answered Oct 06 '22 00:10

Notive