iOS多级列表 - XQMultistageTableView
生活随笔
收集整理的這篇文章主要介紹了
iOS多级列表 - XQMultistageTableView
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
可以自定義子節(jié)點(diǎn)的多級(jí)菜單
1. 多級(jí)菜單
2. 多選/單選
3. 三種Cell樣式<Base 基礎(chǔ)、Default 默認(rèn)、Custom 自定義>
Github XQMultistageTableView 地址
CocoaPods
pod 'XQMultistageTableView', '~> 1.0.6'XQMultistage 提供三種Cell樣式
1、Base 基礎(chǔ)
###使用 XQMultistageAdapter 管理適配器
- (void)viewDidLoad {[super viewDidLoad];_adapter = [[XQMultistageAdapter alloc] init];_adapter.radio = YES;_adapter.delegate = self;_adapter.multistageData = self.data;UITableView * tableView = [[UITableView alloc] initWithFrame:self.view.bounds];tableView.separatorStyle = UITableViewCellSeparatorStyleNone;tableView.dataSource = _adapter;tableView.delegate = _adapter;[self.view addSubview:tableView]; }##2、Default 默認(rèn)
使用 XQMultistageAdapter 管理適配器
- (void)viewDidLoad {[super viewDidLoad];_adapter = [[XQMultistageDefaultAdapter alloc] init];_adapter.delegate = self;_adapter.multistageData = self.data;UITableView * tableView = [[UITableView alloc] initWithFrame:self.view.bounds];tableView.separatorStyle = UITableViewCellSeparatorStyleNone;tableView.dataSource = _adapter;tableView.delegate = _adapter;[self.view addSubview:tableView]; }3、Custom 自定義 ~隨心所欲 ~
使用 XQMultistageAdapter 管理適配器
- (void)viewDidLoad {[super viewDidLoad];_adapter = [[XQMultistageAdapter alloc] init];_adapter.radio = YES;_adapter.delegate = self;_adapter.multistageData = self.data;UITableView * tableView = [[UITableView alloc] initWithFrame:self.view.bounds];tableView.separatorStyle = UITableViewCellSeparatorStyleNone;tableView.dataSource = _adapter;tableView.delegate = _adapter;[self.view addSubview:tableView]; }通過(guò) XQNode 設(shè)置對(duì)應(yīng)的節(jié)點(diǎn)
typedef enum{ XQNodeContentTypeSuper, // 父節(jié)點(diǎn) XQNodeContentTypeSub, // 子節(jié)點(diǎn) }XQNodeContentType; @interface XQNode : NSObject #pragma 共同擁有 /// 節(jié)點(diǎn)名稱(chēng) @property(nonatomic, copy) NSString *title; /// 父節(jié)點(diǎn)的id,如果為-1表示該節(jié)點(diǎn)為根節(jié)點(diǎn) @property (nonatomic , retain) NSNumber *parentId; /// 本節(jié)點(diǎn)的id @property (nonatomic , retain) NSNumber *nodeId; /// 該節(jié)點(diǎn)的深度 @property (nonatomic , assign) int depth; /// 使用者id @property (nonatomic , retain) NSNumber *userId; /// 內(nèi)容類(lèi)型 @property (nonatomic , assign) XQNodeContentType contentType; /// 圖片路徑 @property (nonatomic , copy) NSString *imagePath; #pragma Super /// 子節(jié)點(diǎn)列表 @property (nonatomic, strong) NSMutableArray *subItems; /// 該節(jié)點(diǎn)是否處于展開(kāi)狀態(tài) @property (nonatomic , assign) BOOL isExpand; @end#pragma mark - XQMultistageCellDelegate
/** 自定義Cell*/ - (XQMultistageCell *)xq_multistageAdapter:(XQMultistageAdapter *)adapter tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {static NSString * ID = @"QMultistage";CustomTypeViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];if (!cell) {cell = [[CustomTypeViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];}return cell; }使用 CustomTypeViewCell 配置頁(yè)面
/*** 可以重寫(xiě) setting 方法,對(duì)Cell進(jìn)行改造* 也可繼承 XQMultistageNode, 在使用時(shí)在轉(zhuǎn)換回自的 model*/ @implementation CustomTypeViewCell-(void)setNode:(XQMultistageNode *)node {[super setNode:node];// 此處..... }XQMultistageAdapterDelegate
// 是否關(guān)閉子節(jié)點(diǎn) 默認(rèn)是 NO - (BOOL)xq_multistageAdapterShouldCloseSubNode:(XQMultistageAdapter *) adapter;// 父節(jié)點(diǎn)可不可以點(diǎn)擊 默認(rèn)是 NO - (BOOL)xq_multistageAdapterUnClickSuperNode:(XQMultistageAdapter *) adapter;// cell 點(diǎn)擊事件 - (void)xq_multistageAdapter:(XQMultistageAdapter *) adapter didSelectRowAtNode:(XQMultistageNode *) node;// 選擇展示功能 -> 狀態(tài)改變 - (void)xq_multistageAdapter:(XQMultistageAdapter *) adapter didSelectStateChangeAtNode:(XQMultistageNode *) node selectState:(BOOL) state;// 行高 - (CGFloat)xq_multistageAdapter:(XQMultistageAdapter *) adapter heightForRowAtNode:(XQMultistageNode *) node;// 自定義 cell - (XQMultistageCell *)xq_multistageAdapter:(XQMultistageAdapter *) adapter tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;XQMultistageDefaultAdapterDelegate
// 自定義內(nèi)容左邊內(nèi)邊距 // 可通過(guò) XQMultistageNode -> depth 獲取到當(dāng)前層級(jí)決定縮緊長(zhǎng)度 - (CGFloat)xq_multistageDefaultAdapterToContentLeftInset:(XQMultistageDefaultAdapter *) adapter;/** * 多級(jí)展示節(jié)點(diǎn)展開(kāi)提示圖片功能代理 * 節(jié)點(diǎn)展開(kāi)提示 是在 Cell 的左邊 */// 根節(jié)點(diǎn)展開(kāi)提示圖片圖片 - (UIImage *)xq_multistageDefaultAdapterToRootExpandTipImage:(XQMultistageDefaultAdapter *) adapter;// 節(jié)點(diǎn)展開(kāi)提示圖片圖片 - (UIImage *)xq_multistageDefaultAdapterToExpandTipImage:(XQMultistageDefaultAdapter *) adapter;// 根節(jié)點(diǎn)展開(kāi)提示圖片 是否可以旋轉(zhuǎn) - (BOOL)xq_multistageDefaultAdapterToRootExpandTipImageIsRotation:(XQMultistageDefaultAdapter *) adapter;/** * 多級(jí)展示選擇功能代理 * 節(jié)點(diǎn)選擇圖片是在 Cell 的右邊 */// 是否啟用選擇展示功能 配合 XQMultistageNode->selectState 使用 - (BOOL)xq_multistageDefaultAdapterToSelectOperation:(XQMultistageDefaultAdapter *) adapter;// 選擇展示功能 -> 選中狀態(tài)圖片 - (UIImage *)xq_multistageDefaultAdapterToImageStateSelected:(XQMultistageDefaultAdapter *) adapter;// 選擇展示功能 -> 未選中狀態(tài)圖片 - (UIImage *)xq_multistageDefaultAdapterToImageStateNormal:(XQMultistageDefaultAdapter *) adapter;Remind
ARC iOS>=6.0 iPhone \ iPad screen anywayXQKit 交流:546456937
總結(jié)
以上是生活随笔為你收集整理的iOS多级列表 - XQMultistageTableView的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: windows10与windows98虚
- 下一篇: 如何解决eclipse黑底白字快速需求