日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

iOS多级列表 - XQMultistageTableView

發布時間:2023/12/14 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 iOS多级列表 - XQMultistageTableView 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

可以自定義子節點的多級菜單

1. 多級菜單

2. 多選/單選

3. 三種Cell樣式<Base 基礎、Default 默認、Custom 自定義>

Github XQMultistageTableView 地址

CocoaPods

pod 'XQMultistageTableView', '~> 1.0.6'

XQMultistage 提供三種Cell樣式

1、Base 基礎

###使用 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 默認

使用 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]; }

通過 XQNode 設置對應的節點

typedef enum{ XQNodeContentTypeSuper, // 父節點 XQNodeContentTypeSub, // 子節點 }XQNodeContentType; @interface XQNode : NSObject #pragma 共同擁有 /// 節點名稱 @property(nonatomic, copy) NSString *title; /// 父節點的id,如果為-1表示該節點為根節點 @property (nonatomic , retain) NSNumber *parentId; /// 本節點的id @property (nonatomic , retain) NSNumber *nodeId; /// 該節點的深度 @property (nonatomic , assign) int depth; /// 使用者id @property (nonatomic , retain) NSNumber *userId; /// 內容類型 @property (nonatomic , assign) XQNodeContentType contentType; /// 圖片路徑 @property (nonatomic , copy) NSString *imagePath; #pragma Super /// 子節點列表 @property (nonatomic, strong) NSMutableArray *subItems; /// 該節點是否處于展開狀態 @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 配置頁面

/*** 可以重寫 setting 方法,對Cell進行改造* 也可繼承 XQMultistageNode, 在使用時在轉換回自的 model*/ @implementation CustomTypeViewCell-(void)setNode:(XQMultistageNode *)node {[super setNode:node];// 此處..... }

XQMultistageAdapterDelegate

// 是否關閉子節點 默認是 NO - (BOOL)xq_multistageAdapterShouldCloseSubNode:(XQMultistageAdapter *) adapter;// 父節點可不可以點擊 默認是 NO - (BOOL)xq_multistageAdapterUnClickSuperNode:(XQMultistageAdapter *) adapter;// cell 點擊事件 - (void)xq_multistageAdapter:(XQMultistageAdapter *) adapter didSelectRowAtNode:(XQMultistageNode *) node;// 選擇展示功能 -> 狀態改變 - (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

// 自定義內容左邊內邊距 // 可通過 XQMultistageNode -> depth 獲取到當前層級決定縮緊長度 - (CGFloat)xq_multistageDefaultAdapterToContentLeftInset:(XQMultistageDefaultAdapter *) adapter;/** * 多級展示節點展開提示圖片功能代理 * 節點展開提示 是在 Cell 的左邊 */// 根節點展開提示圖片圖片 - (UIImage *)xq_multistageDefaultAdapterToRootExpandTipImage:(XQMultistageDefaultAdapter *) adapter;// 節點展開提示圖片圖片 - (UIImage *)xq_multistageDefaultAdapterToExpandTipImage:(XQMultistageDefaultAdapter *) adapter;// 根節點展開提示圖片 是否可以旋轉 - (BOOL)xq_multistageDefaultAdapterToRootExpandTipImageIsRotation:(XQMultistageDefaultAdapter *) adapter;/** * 多級展示選擇功能代理 * 節點選擇圖片是在 Cell 的右邊 */// 是否啟用選擇展示功能 配合 XQMultistageNode->selectState 使用 - (BOOL)xq_multistageDefaultAdapterToSelectOperation:(XQMultistageDefaultAdapter *) adapter;// 選擇展示功能 -> 選中狀態圖片 - (UIImage *)xq_multistageDefaultAdapterToImageStateSelected:(XQMultistageDefaultAdapter *) adapter;// 選擇展示功能 -> 未選中狀態圖片 - (UIImage *)xq_multistageDefaultAdapterToImageStateNormal:(XQMultistageDefaultAdapter *) adapter;

Remind

ARC iOS>=6.0 iPhone \ iPad screen anyway

XQKit 交流:546456937

總結

以上是生活随笔為你收集整理的iOS多级列表 - XQMultistageTableView的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。