how to switch between multiple views using view controller(with the help of IBAction) ?
This is the code I have written so far:
In the interface file I have made an IBAction:
-(IBAction)Next;
and in the implementation file I have written this:
- (IBAction)Next
{
SecondPopovercontrol *second = [[SecondPopovercontrol alloc] initWithNibName:nil bundle:nil];
[self presentingViewController:second animated: YES completion:NULL]; // This is the step I am facing issues with
}
I am unable to get this running- the name of the 2 view controllers are: WOMPopoverController
and SecondPopovercontrol
.
The error is:
"No visible @interface for WOMPopoverController declares the selector presenting Viewcontroller:animated:completion"
I am new to StackExchange, so if there is any inconsistency in my question please let me know. And, please guide me about how to solve this issue.
thank you
presentingViewController
is a property of a UIViewController. It holds a pointer to the viewController that presented the current viewController (or nil if this viewController was not presented by a presenting viewController).
What you meant to do was send a presentViewController:animated:completion
message to self
:
[self presentViewController:second animated:YES completion:nil];
(that's 'present', not 'presented')
When second
is presented, it's presentingViewController
property will be set to this self, and self's presentedViewController
property will be set to second
edit
as Jef has pointed out, I have mistakenly assumed you are dealing with iOS. On OSX, the approach is similar. An NSViewController has a presentingViewController
property, and a presentedViewControllers
array. The various presenting methods available to you differ:
– presentViewController:animator:
– presentViewController:asPopoverRelativeToRect:ofView:preferredEdge:behavior:
– presentViewControllerAsModalWindow:
– presentViewControllerAsSheet:
IN any case I think you need to consider the NSViewController documentation carefully to be sure you are using the correct approach for the correct platform (your erroneous method seems to be derived from iOS, not OSX).
edit 2
I have made a small demo app showing the various presentation behaviours for NSViewController
on OSX, including a very basic custom animator object.