I have an iPad app (XCode 4.6, iOS 6.2, Storyboards, ARC) where I created a UIViewController (not connected to any segue) to be used in a UIPopover. These are the ViewController settings:
I have this code that is supposed to display the "viewForPopover" ViewController from within a UIPopover.
UIView *anchor = textField;
UIViewController *viewControllerForPopover =
[self.storyboard instantiateViewControllerWithIdentifier:@"viewForPopover"];
popover = [[UIPopoverController alloc]
initWithContentViewController:viewControllerForPopover];
[popover presentPopoverFromRect:anchor.frame
inView:anchor.superview
permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
My problem is: there is no self.storyboard. So how am I supposed to get to the view controller which lies outside of the current class? (current class is a subview of UIView)
Call this method on UIStoryboard:
+ (UIStoryboard *)storyboardWithName:(NSString *)name bundle:(NSBundle *)storyboardBundleOrNil
probably like this if your view controller live in 'MainStoryboard.storyboard':
UIViewController *viewControllerForPopover =
[[UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]instantiateViewControllerWithIdentifier:@"viewForPopover"];