程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> uitableview-關於給指定的table加標題

uitableview-關於給指定的table加標題

編輯:編程綜合問答
關於給指定的table加標題

在工程中有兩個UITableView,然後我給其中一個加自定義標題:

- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    if(tableView.tag == 3)
    {
    SectionInfo *array  = [self.sectionInfoArray objectAtIndex:section];
    if (!array.sectionView)
    {
        NSString *title = array.groupdeck.groupTitle;
        array.sectionView = [[SectionView alloc] initWithFrame:CGRectMake(0, 0, tblData.bounds.size.width, 45) WithTitle:title Section:section delegate:self];
    }
    return array.sectionView;
    }
    else{
        return 0;
    }

return 0;
}

然後就會出現如下結果:

CSDN移動問答

但是別的表標題就是默認的,還會return 0

CSDN移動問答

最佳回答:


試試:

otherTable.sectionHeaderHeight = 0.0;

不用再加別的了。

或者:

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section 
 { 
      if(tableView.tag == 3)
      {
          //Required height.
      }
      else
      {
          return 0.0; 
      }
 }
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved