CCDebugHelper 1.0.2

CCDebugHelper 1.0.2

测试已测试
语言语言 Obj-CObjective C
许可 MIT
发布最新发布2014年12月

Rafał Wójcik 维护。



  • Rafał Wójcik

CCDebugHelper 是一个用于加速应用程序调试的库。您可以通过定义您的应用中的所有视图控制器,轻松决定哪个视图控制器应该出现在启动时或列出所有定义的控制器,而不是通过点击界面来获取正确的视图控制器。但这并非一切。您还可以定义前置动作来准备控制器显示。有同步和异步两种前置动作版本。

警告

此库用于调试,因此永远不要将其留在 AppStore 版本中!!!

如何开始

Podfile

platform :ios, '7.0'
pod "CCDebugHelper", "~> 1.0.0"

使用

安装后,首先需要做的就是创建我们的 `CCDebugHelper` 类的子类。您可以随意命名它。在这个例子中,我将使用 `MyDebugHelper` 类。

必须重写名为 `- (NSArray *)viewControllersConfigs;` 的方法,并返回一个 `CCViewControllerConfig` 类对象的数组。

在单个 `CCViewControllerConfig` 对象上,您可以指定用于设置视图控制器和添加前置动作的内容。

要简单地使用列表视图,您需要在内置应用程序的 `application:didFinishLaunchingWithOptions:` 方法中添加几行代码。

// initialize CCDebugHelper with application window
MyDebugHelper *viewDebuger = [[MyDebugHelper alloc] initWithWindow:self.window];

// tell CCDebugHelper to show list of controllers
[viewDebuger showControllersList];

如果您想显示特定的控制器,可以使用以下方法:

// this method will show first view controller from config list
[viewDebuger showControllerWithConfigIndex:0];

CCViewControllerConfig

通过故事板

+ (instancetype)configWithName:(NSString *)name
                 forController:(Class)controllerClass
          storyboardIdentifier:(NSString *)storyboardIdentifier
                    storyboard:(UIStoryboard *)storyboard;

通过 XIB

// When controller name is the same like XIB name
+ (instancetype)configWithName:(NSString *)name
                 forController:(Class)controllerClass;

// for custom XIB name uose this method
+ (instancetype)configWithName:(NSString *)name
                 forController:(Class)controllerClass
                       xibName:(NSString *)xibName;

示例

CCViewControllerConfig *config = [CCViewControllerConfig configWithName:@"Profile"
                                                          forController:[ProfileViewController class]
                                                   storyboardIdentifier:@"ProfileViewController"
                                                             storyboard:[UIStoryboard storyboardWithName:@"Main" bundle:nil]];

// wrap controller with navigation controller
[config setShouldWrapControllerWithNavigationController:YES];

// set custom navigation controller class
[config setNavigationControllerClass:[MyCustomNavigationControllerClass class]];

要将控制器封装在导航控制器中,设置属性 `shouldWrapControllerWithNavigationController`

要使用自定义导航控制器类,设置属性:navigationControllerClass

CCBeforeAction

添加同步动作(如准备过渡)

CCBeforeAction *preapareProfileViewControllerAction = [[CCBeforeAction alloc] initSyncActionWithName:@"Setting username" actionBlock:^(ProfileViewController *controller) {
    controller.username = @"chillicoder";
}];
[config addBeforeAction:preapareProfileViewControllerAction];

添加异步动作

CCBeforeAction *loginAction = [[CCBeforeAction alloc] initAsyncActionWithName:@"Login" actionBlock:^(id controller, CCViewControllerConfigComplete complete) {

    // do async stuff for login

    // you need call complete callback for asynchronized actions
    complete();
}];
[config addBeforeAction:preapareProfileViewControllerAction];

待办事项

  • [x] XIB 示例
  • [ ] 支持 XIB 或 Storyboards 之外的控制器
  • [ ] 支持 iPad(加载控制器和列表视图布局)
  • [ ] 添加选项以使用数据源代理而非子类来设置 CCDebugHelper