簡體   English   中英

UITableView - 如何滾動標題部分以及表格視圖單元格?

[英]UITableView - How to Scroll header section along with table view cell?

我在uitableview中的每個部分都有動態單元格和動態頁眉視圖。 我們為tableview單元啟用標題滾動嗎?

將表格樣式更改為xib中的Grouped。

如果我們必須為iOS 6和7顯示相同的UI方法,我們在scrollview委托中使用了上述方法。

添加實際擁有的部分數量的兩倍。 讓偶數段只有段標題,而奇數段只應有沒有段標題的行。

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return double the number of sections.
return ([_arrSection count]*2);
}

和..

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
//Even Sections will have only header and no rows 
if(section%2 == 0)
    return 0;

//Number of rows return only is the section is expanded else return 0
return [arrRowsForSpecificSection count];
}

和...

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
//Odd sections will have no header
if(section%2 == 1)
    return 0;

//for even sections
return HEIGHT_FOR_SECTION_HEADER;
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{

//Odd section will have no header
if(section%2 == 1)
    return NULL;
//even section will have header
return Header_View;
}

因此,在運行時,它給人的印象是它是當前部分的標題,滾動而不固定在頂部。 流暢的動畫!!!! 干杯

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM