mardi 4 août 2015

modal segue to a xib from a xib?

I have an app that doesn't use storyboards. I use only Xibs.

Repeat: I AM NOT USING STORYBOARDS. Apologies if you've found this to be a duplicate, but I have only found questions solutions related to storyboards or people attempting to transition from a storyboard to a xib.

I have created a prompt xib that I would like to present modally from a table view controller xib (named TVC.xib) with their respective .h/.m view controller files. The TVC is nested in a navigation controller.

I can get the prompt to present itself, but I want it to present itself modally. Unfortunately, the presentModalViewController has been deprecated. What is the current option to present a view controller modally in code?

Here is my code: (in the TVC.m)

PromptViewController *promptVC = [[PromptViewController alloc] initWithNibName:@"PromptXib" bundle:nil];
UINavigationController *navVC = [[UINavigationController alloc] initWithRootViewController:promptVC];
[self.navigationController presentViewController:navVC animated:YES completion:^{
    NSLog(@"presented prompt vc");
}];

Ideally I could replace the method in the 3rd line with self.navigationController presentMODALViewController... etc, but it's deprecated.

How do I present a xib modally from a xib?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire