UIPages 是 UIKit 类 UIPageViewController 的包装框架。每个页面组件通过 UIPagesDataSource 提供,用于与相关的故事板交互。UIPagesDataSource 类允许我们遍历故事板组件,并在遍历过程中保持当前索引。
UIPages 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中即可
pod "UIPages"
将您的控制器添加到故事板中,然后更新“Storyboard ID”
更新“Storyboard ID”后,您可以在UIPagesDataSource中引用控制器
#import "WalkthroughController.h"
@interface WalkthroughController () <UIPagesDataSource>
@end
@implementation WalkthroughController
-(NSString*)getStoryboardName {
return @"Walkthrough";
}
-(NSArray*)getIdentifiers {
return @[@"suggestions"];
}
@end
之后可在Swift中定义UIPagesDataSource
class WalkthroughController : UIPagesDataSource {
func getStoryboardName() -> String {
return "Walkthrough"
}
func getIdentifiers() -> [AnyObject] {
return ["suggestions"]
}
}
PagesObjCExamples项目有6个屏幕在Walkthrough故事板和控制器中引用。为了演示在应用程序第一次启动时滑动操作将如何工作,此示例使用UISwipes框架。
上述是(六个)Walkthrough屏幕中的两个,显示了如何将演示集成到您的应用程序引导流程中。
要运行示例项目,请克隆仓库,然后从示例目录中首先运行pod install
。
git clone https://github.com/the-mac/pages-controller-ios.git
cd PagesObjCExamples
pod install
open PagesObjCExamples.xcworkspace
对于您自己的项目(和Podfile),我们的UIPages引用可能如下所示
platform :ios, '8.0'
target 'MyAppTarget' do
pod 'UIPages'
end
UIPages 可在 MIT 许可证下使用。有关更多信息,请参阅 LICENSE 文件。