首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >故事板中的UIPopoverPresentationController

故事板中的UIPopoverPresentationController
EN

Stack Overflow用户
提问于 2014-10-19 17:22:08
回答 1查看 787关注 0票数 1

我正在从代码初始化我的UIPopoverPresentationController

代码语言:javascript
复制
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元素。请告诉我,当从代码初始化弹出时,我如何从故事板中获得我的视图。提前谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-10-19 19:05:37

当您在情节提要中创建视图控制器时,应该使用instantiateViewControllerWithIdentifier:而不是alloc init来创建它的实例。

代码语言:javascript
复制
ChoseOptionsViewController *contentController = [self.storyboard instantiateViewControllerWithIdentifier:@"Whatever"];

确保故事板中的控制器将其标识符设置为传递给方法的相同字符串。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26453247

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档