Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine if a UIViewController has been called as ModalDialog?

In my app I can call a UIViewControle in both mode: Push and ModalDialog.

How can I determine, once the UIViewController is active, if has been called as Push or Modal Dialog ?

like image 616
Fulkron Avatar asked Mar 09 '11 20:03

Fulkron


People also ask

When is the UIViewController’s view method called?

This method is called after the UIView that is this UIViewController ’s View property is removed from the display UIView hierarchy. Called after the View has laid out its subviews. Called after the controller’s View is loaded into memory. In iOS 6 and later, this method is never called.

When is the UIViewController resizing method called in iOS?

This method is called prior to the removal of the UIView that is this UIViewController ’s View from the display UIView hierarchy. Called before the View lays out its subviews. For UIViewController objects that are part of an app extension, called prior to the View being resized. In iOS 6 and later, this method is never called.

When is UIViewController called in iOS 6?

Called before the View lays out its subviews. For UIViewController objects that are part of an app extension, called prior to the View being resized. In iOS 6 and later, this method is never called. In prior versions it was called prior to the controller’s view was released from memory.

What is a uinavigationcontroller?

A standard UINavigationController for reviewing and editing video and audio files. Top-level controller that presents view controllers one at a time, selected by a toolbar along the bottom of the screen. A standard view controller that presents a term and it's dictionary definition.


2 Answers

You can check modalViewController property of parent view controller like this:

if ([self.parentViewController.modalViewController isEqual:self]) {
    NSLog(@"Modal");
} else {
    NSLog(@"Push");
}

Just remember to check it after the view has been pushed/presented.

like image 196
suda Avatar answered Sep 30 '22 20:09

suda


This works for me:

   if(self.presentingViewController){
        //modal view controller 

    }else{


    }
like image 38
sash Avatar answered Sep 30 '22 21:09

sash