Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible for my UIViewController to detect whether it is being displayed in a UIPopoverController or not?

I would like to use one view controller for both an iPhone view and an iPad PopOverView. If the view is displayed in a popover, I would like to do some minor reformatting of the UI.

Is it possible for my UIViewController to detect whether it is being displayed in a UIPopoverController?

I've found the contentSizeForViewInPopover property, which is great for resizing the view, but I would like to remove/hide an element if the view is loaded in a PopOverView.

like image 576
cmorgan5555 Avatar asked Jan 28 '11 18:01

cmorgan5555


2 Answers

I do not think it is possible. I've tried looking at the class of the parentViewController, as well as the class of the presentingViewController, and both are null. Without them providing a property on UIViewController similar to the navigationController property, it can't be done.

like image 198
Mark Avatar answered Nov 15 '22 05:11

Mark


you can override below method in your class and manage it with BOOL variable or some functions

- (CGSize)contentSizeForViewInPopover
{
    popovermode = YES;
    [self callhideMethod];
    return CGSizeMake(320, 200);
}

it might help you.

like image 26
Paras Gandhi Avatar answered Nov 15 '22 07:11

Paras Gandhi