objective-c – 如何在Interface Builder中使用Storyboard连接Page View Controller的数据源插座

栏目: Objective-C · 发布时间: 5年前

内容简介:请注意,Apple文档说明UIPageViewController通常不是子类.您的UIPageViewControllerDataSource不需要是View Controller的子类.您可以使其成为NSObject的子类.通常只有在故事板上出现的东西,即UI元素,才会显示在故事板左侧的文档轮廓中(只要它没有被隐藏).如果您的委托/数据源尚未存在,则可以在适当的场景中将“对象”(黄色立方体)拖放到文档大纲中.然后单击刚刚添加的对象,并使用“身份检查器”窗格将其具体的类更改为数据源类.然后可以通过从“连
根据Apple的文档 here

,我们应该可以将一个Page View Controller添加到故事板中,然后通过连接插座可选地设置数据源.

Creating a Page View Controller Interface Using a Storyboard

The Page-Based Application Xcode template creates a new project with a page view controller as the initial scene.

To add a page view controller to an existing storyboard, do the following:

  1. Drag a page view controller out of the library. Add a page view controller scene to your storyboard.
  2. In the Attributes inspector, set up the appropriate options.
  3. Optionally, set a delegate, a data source, or both by connecting the corresponding outlets.
  4. Display it as the first view controller by selecting the option Is Initial View Controller in the Attributes inspector (or present the view controller in your user interface in another way.)

那么我就这样定义了一个UIPageViewController子类

@interface DetailsPageViewController : UIPageViewController <UIPageViewControllerDataSource>

但是当我尝试连接数据源插座时,它不会突出显示控制器或允许连接它.我也尝试在其他控制器上实现UIPageViewControllerDataSource,但是我也遇到不能连接插座的问题.

谁能帮忙?

请注意,Apple文档说明UIPageViewController通常不是子类.您的UIPageViewControllerDataSource不需要是View Controller的子类.您可以使其成为NSObject的子类.

通常只有在故事板上出现的东西,即UI元素,才会显示在故事板左侧的文档轮廓中(只要它没有被隐藏).如果您的委托/数据源尚未存在,则可以在适当的场景中将“对象”(黄色立方体)拖放到文档大纲中.

然后单击刚刚添加的对象,并使用“身份检查器”窗格将其具体的类更改为数据源类.然后可以通过从“连接”检查器拖动一行到其上,以正常方式用作连接的目标.

http://stackoverflow.com/questions/13171360/how-to-connect-datasource-outlet-of-a-page-view-controller-using-storyboard-in-i


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

HTML5与CSS3基础教程(第8版)

HTML5与CSS3基础教程(第8版)

[美] Elizabeth Castro、[美] Bruce Hyslop / 望以文 / 人民邮电出版社 / 2014-5 / 69.00元

本书是风靡全球的HTML和CSS入门教程的最新版,至第6版累积销量已超过100万册,被翻译为十多种语言,长期雄踞亚马逊书店计算机图书排行榜榜首。 第8版秉承作者直观透彻、循序渐进、基础知识与案例实践紧密结合的讲授特色,采用独特的双栏图文并排方式,手把手指导读者从零开始轻松入门。相较第7版,全书2/3以上的内容进行了更新,全面反映了HTML5和CSS3的最新特色,细致阐述了响应式Web设计与移......一起来看看 《HTML5与CSS3基础教程(第8版)》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器