CCNNavigationController 1.1.7

CCNNavigationController 1.1.7

测试已测试
简称语言 Obj-CObjective C
许可证 MIT
发布最新发布2017年6月

Frank Gregor 维护。



  • 作者
  • Frank Gregor

macOS 导航控制器

一个类似 iOS 中对应物 UINavigationController 的 macOS 导航控制器,使用确切的方法命名(一些添加)。

这个控制器的原始想法来自于 Heiko Dreyer 的 BFNavigationController。最初我 fork 了他的仓库,但由于进行了许多修改和添加,所以我决定自己动手。因此,这个代码的某些部分可能看起来和他的相似。(-;

安装

您可以通过将所有 .h.m 文件复制到您的项目中来手动完成它,或者您可以在 Podfile 中添加以下行

pod 'CCNNavigationController'

如何使用它

使用 CCNNavigationController 没有什么特别的。如果您熟悉 iOS 的 UINavigationController,您应该从一开始就能使用它。与 Heiko 的 BFNavigationController 不同,您不需要提供一个初始框架。只需设置您的 rootViewController,然后完成。剩下的将自动处理。您也可以通过 CCNNavigationControllerConfiguration 对象设置一些配置选项。

有两种方式可以给导航控制器它的根视图控制器

1. 在 CCNNavigationController 的初始化期间直接设置根视图控制器。
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
    
   MyRootVC *rootVC = [[MyRootVC alloc] init];
   CCNNavigationController *navigationController = [[CCNNavigationController alloc] initWithRootViewController:rootVC];
    
   // you can set some configuration options
   navigationController.configuration.transition = CCNNavigationControllerTransitionToDown;
   navigationController.configuration.transitionStyle = CCNNavigationControllerTransitionStyleStack;
   
   // make the navigation controller the window's content view controller
   self.window.contentViewController = navigationController;

   ...
}
2. 用 nil 根视图控制器初始化 CCNNavigationController
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
    
   CCNNavigationController *navigationController = [[CCNNavigationController alloc] initWithRootViewController:nil];
   
   // make the navigation controller the window's content view controller
   self.window.contentViewController = navigationController;


   //  do some other stuff...
   
   // initialize your rootViewController and set it as navigationController's first object
   MyRootVC *rootVC = [[MyRootVC alloc] init];
   navigationController.viewControllers = @[ rootVC ];
}

CCNNavigationController-Example

文档

您将在 CocoaDocs 上找到一个完整的文档。

贡献

代码以现有形式提供,远远没有完整或无瑕疵。如果您喜欢这个组件,请自由支持它。根据您的需求进行修改,扩展它或仅在自己的项目中使用。非常欢迎提交Pull Requests和反馈。请通过以下邮箱联系我:[email protected] 或在Twitter上发个消息给我 @TheCocoaNaut

许可证

本软件遵循