objective-c - 如何在 Interface Builder 中使用 Storyboard连接页面 View Controller 的数据源导出

标签 objective-c interface-builder uistoryboard uipageviewcontroller

根据 Apple 文档 here ,我们应该能够将一个页面 View Controller 添加到 Storyboard 中,然后可以选择通过连接 socket 来设置数据源。

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>

但是当我尝试连接数据源 socket 时,它不会突出显示 Controller 或允许连接它。我也尝试在其他 Controller 上实现 UIPageViewControllerDataSource,但我遇到了无法连接 socket 的相同问题。

有人能帮忙吗?

最佳答案

我没能在 IB 中找到实现它的方法。必须改用以下内容:

self.delegate=self;
self.dataSource=self;

关于objective-c - 如何在 Interface Builder 中使用 Storyboard连接页面 View Controller 的数据源导出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13171360/

相关文章:

iphone - [[UIApplication sharedApplication] delegate] 的简写?

ios - UIScrollview 是否与 UIStatusbar 一起正常工作?

swift - 使用 IBDesignable 以编程方式从 Assets 访问 NSImage

ios - Storyboard无法实例化名为 UIStoryboardUnwindSegueTemplate 的类崩溃

ios - 从 Storyboard 获取 ViewController

ios - 地址簿 UI 框架弃用的方法

iphone - 如何旋转 UIView?

ios - AvAudioRecorder 在录音刚开始后停止/重启

iphone - 从 Nib 加载的 View 未获取触摸事件

ios - 如何以正确的方式使用导航 Controller 实现标签栏 Controller