So there are few ways how to do it:
First way:
Add observer to ipadMainViewController initialization method or viewDidLoad method it depends on your needs.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(buttonPressed)
name:@"kNotificationDidPressedButon"
object:nil];
Add -buttonPressed
method to ipadMainViewController controller for removing your view or other your purposes.
- (void)buttonPressed
{
// remove view here
}
in the CategoriesViewController in the method where you tap on the appropriate button add this code:
[NSNotificationCenter defaultCenter] postNotificationName:@"kNotificationDidPressedButon"
object:self];
Second way:
Add delegate property to CategoriesViewController. you can find info how to make delegate for example here: link
Third way:
Use objective-c blocks
Initial advice as for beginner:
I suggest you to start from first way, because it is most simplest for understanding. Also you have to remove observer in ipadMainViewControllerr in -dealloc
or -viewWillDisapper
method, it depends of where you have add observer e.g. in -init
method or in -viewDidLoad
or -viewWillAppear
callback;
[[NSNotificationCenter defaultCenter] removeObserver:self];