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

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

内容简介:请注意,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


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

查看所有标签

猜你喜欢:

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

The Sovereign Individual

The Sovereign Individual

James Dale Davidson、William Rees-Mogg / Free Press / 1999-08-26 / USD 16.00

Two renowned investment advisors and authors of the bestseller The Great Reckoning bring to light both currents of disaster and the potential for prosperity and renewal in the face of radical changes ......一起来看看 《The Sovereign Individual》 这本书的介绍吧!

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

Markdown 在线编辑器

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具