RKSwipeBetweenViewControllers 0.1.4

RKSwipeBetweenViewControllers 0.1.4

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布上次发布2015年4月

Richard KimRichard Kim 维护。




UIPageViewController 与自定义 UISegmentedControl 同步和动画。类似于 Spotify 的 "我的音乐" 部分。

请检查 .h 文件以了解如何自定义任何内容

Pod

在大多数情况下,您不应该使用 pod,因为它们不允许自定义。我建议将 .h 和 .m 文件手动拖到您的项目中。

pod 'RKSwipeBetweenViewControllers'

更新、问题和请求

twitter <--- 我是一个很轻的twitterer,所以我不会打扰你

演示

(自定义五分钟后)

demo

理论上任何数量的任何视图控制器都应该可以工作,但是如果有超过 4 个,看起来可能不是很好

可自定义!

Customizable!

(检查 RKSwipeBetweenViewControllers.h 了解实际可自定义功能)

如何使用

(查看提供的 AppDelegate 了解示例)

程序化(首选)

  1. 导入 RKSwipeBetweenViewControllers.h

    #import <RKSwipeBetweenViewControllers/RKSwipeBetweenViewControllers.h>
  2. 初始化一个 UIPageViewController

    UIPageViewController *pageController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];
  3. 初始化一个 RKSwipeBetweenViewControllers

    RKSwipeBetweenViewControllers *navigationController = [[RKSwipeBetweenViewControllers alloc]initWithRootViewController:pageController];
  4. 按顺序将所有视图控制器添加到 navigationController.viewControllerArray 中(尽量保持低于 5)

    [navigationController.viewControllerArray addObjectsFromArray:@[viewController1, viewController2, viewController3]];
  5. 使用自定义类(或将其作为从应用程序代理的第一个控制器调用:见下文)

    self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
    self.window.rootViewController = navigationController;
    [self.window makeKeyAndVisible];

StoryBoard(不要为此使用 pods)

  1. 将文件放入您的项目中并导入 RKSwipeBetweenViewControllers.h

    #import RKSwipeBetweenViewControllers.h
  2. 在 UINavigationController 中嵌入一个 UIPageViewController。将 UINavigationController 的类更改为自定义类(RKSwipeBetweenViewControllers)

  3. 将页面视图控制器的过渡样式改为滚动(在故事板中的 UIPageViewController 上单击 -> 属性检查器 -> 过渡样式 -> 滚动)

  4. 转到 RKSwipeBetweenViewControllers.m 文件并现在将其用作自己的类。将您的视图控制器添加到 "viewControllerArray"。下面有多个选项。

    程序化,在 RKSwipeBetweenViewControllers.m 之外(如果不是第一个出现的屏幕或者要从委托调用它时)

    [customNavController.viewControllerArray addObjectsFromArray:@[viewController1, viewController2, viewController3]];

    程序化,在 RKSwipeBetweenViewControllers.m 之中(如果您的视图控制器是程序化创建的,通常是这种情况)

    [viewControllerArray addObjectsFromArray:@[demo,demo2]];

    故事板,在 RKSwipeBetweenViewControllers.m 之中(如果您的视图控制器在故事板中,但请确保为他们提供故事板 ID)

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
        UIViewController* theController = [storyboard instantiateViewControllerWithIdentifier:@"storyboardID"];
    
        [viewControllerArray addObject:theController];

    故事板,在 RKSwipeBetweenViewControllers.m 之外(如果您的视图控制器在故事板中,但请确保为他们提供故事板 ID)

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
        UIViewController* theController = [storyboard instantiateViewControllerWithIdentifier:@"storyboardID"];
    
        [theCustomViewController.viewControllerArray addObject:theController];

有任何问题/问题?给我发个信息

改进/参与领域

  • 与横向布局协作
  • 处理超过5个页面
  • 少量不经常出现的错误
  • 加载数据时性能更好
  • 将布局从UINavigationController更改为允许条目在底部显示
  • 错误:在Storyboard中将MKMapView添加到UIViewController会导致奇特的视觉错误。程序化添加没有问题
  • UITabBarControllers加载崩溃:https://github.com/cwRichardKim/RKSwipeBetweenViewControllers/pull/15