第三方库QuickDialog使用解析

  QuickDialog能够帮助开发者快速建立复杂的表单,实现包括登陆界面在内的各类样式的TableView输入界面,此外,还能够建立带有多个文本域的表格及项目。
    QuickDialog经过对数据元素的峰值封装,根据不一样元素的使用来简化UITableView的使用。
   为了使用QuickDialog你必须知道三个不一样的类:
     QuickDialogController——UITableViewController的子类,用于显示对话框在你的用中你可能会个类的子类来示。
     QRootElement——一个对话框的根元素,sectionscells的容器,用户显示用数据。每个QuickDialogController一次只能够示一个RootElement。能够包含其余的rootElement的。
     QElement——一个element映射一个UItableViewCell,尽管它包括更多的功能,像可以从cell中读取值和有多个类型。QuickDialog也提供了多种内建element type,像 ButtonElement 和 EntryElement,但你也可以建立本身的element。

一 关于Elements
    QuickDialog 提供了能够应用于app的不少不一样elements。
     QLabelElement: 简单的内建键值对映射
     QBadgeElement: 想label cell,但值是做为一个徽标显示的 
     QBooleanElement: 显示一个开关
     QButtonElement: 在中间显示一个标题想一个button同样
     QDateTimeElement:容许你编辑dates,time,或者date + time值。编辑发生在新朴实出来的viwController中。
     QEntryElement: 输入字段,容许你收集用户的信息。能够自动扩展。     
     QDecimalElement: 很是想一个可输入的field,可是只容许输入数字。能够预约义输入的精度。
     QFloatElement: 显示一个滑动栏 
     QMapElement: 当被选中时,显示一个有location的全屏地图,须要经纬度值。
     QRadioElement:容许用户从多个可利用的选项中选择一个。自动push一个新的有已被选中的item的table。
     QTextElement:  可提供字体渲染的自由文本
     QWebElement: push一个在element中定义URL的简单浏览页面。

下面看下QuickDialog中element的继承关系:


                                                                element 关系图

二 关于Sections
     sections 是一个简单的elements分组,默认状况下有一下几种特性:
     title/footer:页眉/页脚部分显示为简单的字符串
     headerView/footerView:这种状况下,Views能够替换掉titles的显示,能够简单的显示图片或自定义的Views

关于sections的结构图以下:
          
QRadioSection:内联的显示多个选项,而不是到另外一个UIViewController中。
QSortingSection:自动在sections中对cells进行排序。


三 关于自定义的UITableViewCell
  在QuickDialog中自定义了一部分的UITableViewCell,来对应于定义的elements。其结构以下:




四 关于QuickDialog的使用
     集成QucikDialog到项目中:
     最简单的方法是把quickDialog做为git子模块添加到你的现有工程中,而后做为一部分导入到project中。
Terminal:
     cd *your-project-location*
   git submodule add git@github.com:escoz/QuickDialog.git

这种方法是从github中自动copy的,所以你在未来能够方便的更新。

在XCode中:
     打开已存在的project(或者建立个新的)
      把从github分支上下载的QuickDialog.xcodeproj拖拽到你的工程中(root或framework下)
     在工程配置下:
          在Build Phases,添加QuickDialog(the lib, not the example app)做为目标依赖
          在Build Phases->Link binary with libraries下,添加这两个库:MapKit.framework and CoreLocation.framework
          在Link binary with libraries下添加这个QuickDialog.a静态库
在你的prefix.pch未见中,添加#import <QuickDialog/QuickDialog.h>
在你的工程配置中的“Build Settings”下
     本地的"User Header Search Paths"设置,并设置值为"${PROJECT_DIR}/QuickDialog"(包括引号!)而且勾选"Recursive"选项。
     Debug值应当已经被设置,若是没有,修改它。
     本地的 “Always Search User Paths”设置为YES
     最后找到 “Other Linker Flags”选择项,而且添加至-ObjC
OK,that should be all there is.
Here’s how you can create and display your first dialog from inside another UIViewController:
QRootElement *root = [[QRootElement alloc] init];
root.title = @"Hello World";
root.grouped = YES;
QSection *section = [[QSection alloc] init];
QLabelElement *label = [[QLabelElement alloc] initWithTitle:@"Hello" Value:@"world!"];

[root addSection:section];
[section addElement:label];

UINavigationController *navigation = [QuickDialogController controllerWithNavigationForRoot:root]; [self presentModalViewController:navigation animated:YES];
The code above will create the form below:



五:QuickDialog的数据交互
     因为QuickDialog是经过对数据的封装实现对UI的控制的,因此要得到数据的话有两种方式,一种是直接经过elements的属性获取,一种是经过bind的对应键值来使用fetchValueUsingBindingsIntoObject来拉去的。这样的话必须bind中的key与放入对象的attribute的名称要一直,不然会拉去不到crash。

  对QuickDialogTableView的点击事件能够直接设置block来进行控制,这样较容易控制的。git

相关文章
相关标签/搜索