2018/4/9更新
增加自定義cell接口饥侵,對原先函數(shù)命名方式調(diào)整鸵赫,一些bug修改
使用方式和使用picker view相似:
1、創(chuàng)建TablePickerView:
- (instancetype)initWithFrame:(CGRect)frame delegate:(id<TablePickerViewDataSource,TablePickerViewDelegate>)delegate;
2躏升、實(shí)現(xiàn)數(shù)據(jù)源代理TablePickerViewDataSource:
@optional
- (NSInteger)numberOfComponentsInTablePickerView:(TablePickerView *)tablePickerView;
- (NSString *)tablePickerView:(TablePickerView *)tablePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component;
/*!
@brief 自定義每個(gè)選項(xiàng)視圖辩棒,如果現(xiàn)實(shí)該代理方法,tablePickerView:titleForRow: forComponent:方法將無效
*/
- (UITableViewCell *)tablePickerView:(TablePickerView *)tablePickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component;
@required
- (NSInteger)tablePickerView:(TablePickerView *)tablePickerView numberOfRowsInComponent:(NSInteger)component;
3膨疏、實(shí)現(xiàn)視圖代理TablePickerViewDelegate
@optional
- (CGFloat) tablePickerView:(TablePickerView *)tablePickerView widthForComponent:(NSInteger)component;
- (CGFloat) tablePickerView:(TablePickerView *)tablePickerView rowHeightForComponent:(NSInteger)component;
- (void) tablePickerView:(TablePickerView *)tablePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component;
通過以上三步就可以實(shí)現(xiàn)table view 的基礎(chǔ)多級聯(lián)動了一睁,主要視圖在TablePickerView目錄下,具體怎么使用可看源碼:git地址
4佃却、需要自定義cell的話者吁,需要調(diào)用以下方法注冊和獲取復(fù)用cell
/*!
@biref 獲取復(fù)用cell
@param identifier 復(fù)用唯一標(biāo)識
@param component 列
@return 返回tableViewCell
*/
- (UITableViewCell *)dequeueReusableCellWithIdentifier:(NSString *)identifier forComponet:(NSInteger)component;
/*!
@brief 使用xib創(chuàng)建cell
@param identifier 復(fù)用唯一標(biāo)識
@param component 列
*/
- (void)registerNib:(UINib *)nib forCellReuseIdentifier:(NSString *)identifier forComponet:(NSInteger)component;
/*!
@brief 使用純代碼創(chuàng)建cell
@param identifier 復(fù)用唯一標(biāo)識
@param component 列
*/
- (void)registerClass:(Class)cellClass forCellReuseIdentifier:(NSString *)identifier forComponet:(NSInteger)component;