Call presentModalViewController from NSObject Class

In my subclass, NSObjectI would like to name something like

    [[self navController] presentModalViewController:myView animated:YES];

But not one of my attempts was successful. How can I name a modal representation if I'm not in a subclass UIViewController?

Decision:

#import "myProjectNameAppDelegate.h"
// ...
MyViewController *myView = [[MyViewController alloc] init];
myProjectNameAppDelegate *appDelegate = (myProjectNameAppDelegate *)[[UIApplication sharedApplication] delegate];
[[appDelegate navController] presentModalViewController:myView animated:YES];
+5
source share
3 answers

I do not see a way to display a modal view without a ViewController. You must save the UIViewController reference in your class so that you can access it. Or configure the property in AppDelegate, which you can get by calling the delegate [[UIApplication sharedApplication]];

+2
source

currentModalViewController viewcontroller NSobject. NSobject uiviewcontroller

//

[nsobjectclassObject OpenMailComposer:self];// , viewcontroller NSobject class

NSObject//

-(void)OpenMailComposer:(UIViewController*)view
{

    viewControllertoShow = view; // viewControllertoShow is UIVIewcontroller object
    MFMailComposeViewController *mailView = [[MFMailComposeViewController alloc]init];
    mailView.mailComposeDelegate = self;
    [mailView setSubject:@"Hey! check this out!"];
  [viewControllertoShow presentModalViewController:mailView animated:YES];
}

NSObject class

[viewControllertoShow dismissViewControllerAnimated:YES]

+6

navigationController viewController, modal view controller.

myView? , viewController. , viewcontroller , ,

0

All Articles