![](https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1492073124038&di=35256d4479fe234f3d3ef3654768da00&imgtype=0&src=http://file.ipadown.com/uploads/news/20130716142716814.jpg)
對于側(cè)滑欄,相信很多人都用過,下面我將用最簡單的方法實現(xiàn)一下费奸,側(cè)滑欄菜單:
HYXSideBar *hyxsidebar = [[HYXSideBar alloc] init];
hyxsidebar.delegate = self;
hyxsidebar.dataArray = self.dataArray;
[hyxsidebar callSideBarIn:self];
已經(jīng)創(chuàng)建好了一個側(cè)滑欄菜單弥激,如圖:
側(cè)滑欄.gif
并且,該側(cè)滑欄菜單擁有UITableView的所有屬性愿阐,可以通過代理方法一一調(diào)用
/**
獲取相應(yīng)組里面的行數(shù)
@param tableView sidebar里面的tableview
@param section 第幾組
@return 返回的行數(shù)
*/
- (NSInteger)SideBar:( UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
/**
cell的點擊事件
@param tableView sidebar
@param indexPath 點擊的cell位置
*/
- (void)SideBar:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
/**
header的點擊事件
@param tableView sidebar
@param index 點擊的header的位置
*/
- (void)SideBar:(UITableView *)tableView didSelectHeaderAtIndex:(NSInteger )index;
/**
得到相應(yīng)的cell(也是可以隨意自定義的)
@param tableView sidebar里面的tableview
@param indexPath 相應(yīng)位置里面的
@return 返回需要的cell
*/
- (UITableViewCell *)SideBar:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
/**
總組數(shù)
@param tableView SideBar
@return 返回的總組數(shù)
*/
- (NSInteger)numberOfSectionsInSideBar:(UITableView *)tableView;
/**
每一組的header名稱
@param tableView sidebar
@param section 相應(yīng)的組序列
@return 組的名稱
*/
- (NSString *)SideBar:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section;
/**
每一組的footer的名稱
@param tableView sidebar
@param section 相應(yīng)的組序列
@return 每一組的footer名稱
*/
- (NSString *)SideBar:(UITableView *)tableView titleForFooterInSection:(NSInteger)section;
/**
cell生命周期微服,將要描繪出來
@param tableView sidebar
@param cell 將要描繪的cell
@param indexPath cell的位置
*/
- (void)SideBar:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath;
/**
cell的高度
@param tableView sidebar
@param indexPath cell的位置
@return 返回的cell的高度
*/
- (CGFloat)SideBar:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
/**
Header的高度
@param tableView sidebar
@param section 組
@return 高度
*/
- (CGFloat)SideBar:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section;
/**
footer的高度
@param tableView sidebar
@param section 組
@return 高度
*/
- (CGFloat)SideBar:(UITableView *)tableView heightForFooterInSection:(NSInteger)section;
/**
返回一個描述header的view
@param tableView sidebar
@param section 相應(yīng)的組別
@return 返回的viwe
*/
- (UIView *)SideBar:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section;
/**
返回一個描述header的view
@param tableView sidebar
@param section 相應(yīng)的組別
@return 返回的viwe
*/
- (UIView *)SideBar:(UITableView *)tableView viewForFooterInSection:(NSInteger)section;