Fashion view controller view - iPad

I found this code to display a modal view:

- (void)add:(id)sender { // Create the root view controller for the navigation controller // The new view controller configures a Cancel and Done button for the // navigation bar. RecipeAddViewController *addController = [[RecipeAddViewController alloc] initWithNibName:@"RecipeAddView" bundle:nil]; addController.delegate = self; // Create the navigation controller and present it modally. UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:addController]; [self presentModalViewController:navigationController animated:YES]; // The navigation controller is now owned by the current view controller // and the root view controller is owned by the navigation controller, // so both objects should be released to prevent over-retention. [navigationController release]; [addController release]; } 

My question is how to implement this code (I'm going to put it in the buttonPress method)

Do I need to define something in my header file? The bit that bothers me is that apple on provides this file without a header, so I can't say if there should be something there?

The code refers to the RecipieAddViewController, what can I add to this: "UIViewController"?

What do I put as a delegate in the header file? do i need to install this somewhere else? how about the property?

Is there anything else I need to do when I copy this code in my buttonPress method to make it work?

Thanks and sorry for all the questions.

+4
source share
1 answer

My question is how to implement this code (I'm going to put it in the buttonPress method)

Define the method as IBAction as -(IBAction)add:(id)sender , and in the interface builder, associate the touch up inside event with the touch up inside button of a dispatcher object of the form add:

Do I need to define something in my header file? The bit that bothers me is that apple on provides this file without a header, so I can't say if there should be something there?

Nope. UIKit.h needs all these needs UIKit.h Usually you need to change the header to add methods, add instance variables, or include custom classes. However, you may need #import RecipeAddViewController.h somewhere (in your header or implementation file) to use this class. This is true for any custom class that you write that you want to use in another file.

The code refers to the RecipieAddViewController, what can I add to this: "UIViewController"?

Replace this with the view controller class you want to click. UIViewController itself is rarely naked. This is for a subclass. Thus, you create a new class that inherits from the UIViewController , import its title, create an instance of it, and click on the navigation controller.

+4
source

Source: https://habr.com/ru/post/1302211/


All Articles