我有一个iPad应用程序(XCode 4.6,iOS 6.2,Storyboards,ARC),我创建了一个UIViewController(未连接到任何segue),用于UIPopover.这些是ViewController设置:
我有这个代码,应该在UIPopover中显示"viewForPopover"ViewController.
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];
我的问题是:没有self.storyboard.那么我该如何到达当前类之外的视图控制器呢?(当前课程是UIView的子视图)
在UIStoryboard上调用此方法:
+ (UIStoryboard *)storyboardWithName:(NSString *)name bundle:(NSBundle *)storyboardBundleOrNil
如果您的视图控制器存在于'MainStoryboard.storyboard'中,可能是这样的:
UIViewController *viewControllerForPopover =
[[UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]instantiateViewControllerWithIdentifier:@"viewForPopover"];