I have a popover that gets loaded with a navigation controller, which displays the ItemsView xib, and I have a delegate method so this popover can be dismissed from the main view controller. This works perfectly fine, until I drill down to the next level in the UITableView (which loads a detail view). Once the detail view is loaded, I can not call the dismiss method on the main view controller. I am quite new to delegates and would appreciate any guidance. Thank you!
MainView ---> ItemsView -----> DetailView
How to call delegate method located on MainView from DetailView?
//Load the popover with first view:
ItemsView *popoverView = [[ItemsView alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:popoverView];
self.popOverController = [[[UIPopoverController alloc] initWithContentViewController:navController] autorelease];
popoverView.delegate = self;
[navController release];
[popOverController setPopoverContentSize:CGSizeMake(450.0, 300.0)];
[popOverController presentPopoverFromRect:addButton.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
[popoverView release];
Now I push the detail view:
//Push DetailView
if(self.secondView == nil) {
NSLog(@"Called");
AddDetail *viewController = [[AddDetail alloc] initWithNibName:@"AddDetail" bundle:nil];
self.secondView = viewController;
[viewController release];
}
// Setup the animation
secondView.contentSizeForViewInPopover = self.view.bounds.size;
self.contentSizeForViewInPopover = self.view.bounds.size;
[self.navigationController pushViewController:self.secondView animated:YES];
}
Write a property and method in Detail view like following.
while pushing detailviewcontroller call this method as.
now you can call the method declared in Parent as
Hope this helps