我正在从代码初始化我的UIPopoverPresentationController:
ChoseOptionsViewController *contentController = [[ChoseOptionsViewController alloc] init];
contentController.modalPresentationStyle = UIModalPresentationPopover;
UIPopoverPresentationController *copvc = contentController.popoverPresentationController;
copvc.permittedArrowDirections = UIPopoverArrowDirectionAny;
copvc.sourceView = sender;
copvc.sourceRect = sender.bounds;
contentController.preferredContentSize = CGSizeMake(200, 200);
[self presentViewController:contentController animated:YES completion:nil];我得到的只是一个空的200x200视图,尽管我已经在故事板中创建了一个ViewController,为它分配了ChoseOptionsViewController类,并拖动了一些UI元素。请告诉我,当从代码初始化弹出时,我如何从故事板中获得我的视图。提前谢谢。
发布于 2014-10-19 19:05:37
当您在情节提要中创建视图控制器时,应该使用instantiateViewControllerWithIdentifier:而不是alloc init来创建它的实例。
ChoseOptionsViewController *contentController = [self.storyboard instantiateViewControllerWithIdentifier:@"Whatever"];确保故事板中的控制器将其标识符设置为传递给方法的相同字符串。
https://stackoverflow.com/questions/26453247
复制相似问题