【问题标题】:how to change the value of UIPageViewControllerOptionInterPageSpacingKey?如何更改 UIPageViewControllerOptionInterPageSpacingKey 的值?
【发布时间】:2015-01-30 10:02:57
【问题描述】:
我正在尝试在ViewDidAppear() 中设置值UIPageViewControllerOptionInterPageSpacingKey
但是我的 UIPageViewController 的初始化代码在ViewDidLoad()
如果我在视图设置它的布局之前设置UIPageViewControllerOptionInterPageSpacingKey,则自动布局会出现问题
【问题讨论】:
标签:
ios
swift
uiscrollview
ios8
uipageviewcontroller
【解决方案1】:
您必须在初始化时更改页面间距。这可以在 XIB/Storyboard 中完成,或者通过 initWithTransitionStyle:navigationOrientation:options: 方法传递 @{UIPageViewControllerOptionInterPageSpacingKey : @(5.f)}。这在UIPageViewController.h 文件from Apple 中提到:
// Key for specifying spacing between pages in options dictionary argument to initWithTransitionStyle:navigationOrientation:options:.
// Value should be a CGFloat wrapped in an NSNumber. Default is '0'.
// Only valid for use with page view controllers with transition style 'UIPageViewControllerTransitionStyleScroll'.
UIKIT_EXTERN NSString * const UIPageViewControllerOptionInterPageSpacingKey NS_AVAILABLE_IOS(6_0);