iOS UITableView(1)組成結(jié)構(gòu)


tableView組成:

tableView = 一個(gè)tableView HeaderView + 若干個(gè)section + 一個(gè)tableView FooterView ;

section = 一個(gè)section HeaderView + 若干個(gè)cell + 一個(gè)section FooterView ;

tableView組成


tableView HeaderView:

##這里是我的代碼例子:

tableView HeaderView

tableView FooterView:

##這里是我的代碼例子:

tableView FooterView

section:

設(shè)置section的數(shù)量:

- (NSInteger)numberOfSectionsInTableView:(UITableView*)tableView;// Default is 1 if not implemented

##這里是我的代碼例子:

設(shè)置section數(shù)量

section HeaderView:

設(shè)置section headerView的高度:

- (CGFloat)tableView:(UITableView*)tableView heightForHeaderInSection:(NSInteger)section;

設(shè)置section headerView樣式:

- (nullableUIView*)tableView:(UITableView*)tableView viewForHeaderInSection:(NSInteger)section;// custom view for header. will be adjusted to default or specified header height

##這里是我的代碼例子:

section headerView


section FooterView:

設(shè)置section footerView的高度:

- (CGFloat)tableView:(UITableView*)tableView heightForFooterInSection:(NSInteger)section;

設(shè)置 section footerView樣式:

- (nullableUIView*)tableView:(UITableView*)tableView viewForFooterInSection:(NSInteger)section;// custom view for footer. will be adjusted to default or specified footer height

##這里是我的代碼例子:

section footerView

section cell:

設(shè)置cell數(shù)量:

- (NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section;

設(shè)置cell的高度:

- (CGFloat)tableView:(UITableView*)tableView heightForRowAtIndexPath:(NSIndexPath*)indexPath;

設(shè)置cell的樣式:

- (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath;

##這里是我的代碼例子:

section cell

索引:

- (nullableNSArray *)sectionIndexTitlesForTableView:(UITableView*)tableView__TVOS_PROHIBITED;// return list of section titles to display in section index view (e.g. "ABCD...Z#")

##這里是我的代碼例子:

tableView索引
點(diǎn)擊右面索引進(jìn)行快速定位

UITableViewStyle:

- (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style NS_DESIGNATED_INITIALIZER;

其中UITableViewStyle分為以下兩種:

UITableViewStyle

UITableViewStylePlain:

滑動(dòng)tableView時(shí), section(i)的headerView會(huì)保持位置在頂部, 直到下一個(gè)section(i+1)的headerView頂替section(i)的headerView; sectionView的FooterView同理.

UITableViewStylePlain

UITableViewStyleGrouped:

section的headerView, footerView保持跟tableView一起滑動(dòng).

UITableViewStyleGrouped


最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市攀涵,隨后出現(xiàn)的幾起案子淘讥,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 218,451評(píng)論 6 506
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件墅拭,死亡現(xiàn)場(chǎng)離奇詭異申眼,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)潮饱,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,172評(píng)論 3 394
  • 文/潘曉璐 我一進(jìn)店門营罢,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人饼齿,你說我怎么就攤上這事饲漾。” “怎么了缕溉?”我有些...
    開封第一講書人閱讀 164,782評(píng)論 0 354
  • 文/不壞的土叔 我叫張陵考传,是天一觀的道長(zhǎng)。 經(jīng)常有香客問我证鸥,道長(zhǎng)僚楞,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,709評(píng)論 1 294
  • 正文 為了忘掉前任枉层,我火速辦了婚禮泉褐,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘鸟蜡。我一直安慰自己膜赃,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,733評(píng)論 6 392
  • 文/花漫 我一把揭開白布揉忘。 她就那樣靜靜地躺著跳座,像睡著了一般。 火紅的嫁衣襯著肌膚如雪泣矛。 梳的紋絲不亂的頭發(fā)上疲眷,一...
    開封第一講書人閱讀 51,578評(píng)論 1 305
  • 那天,我揣著相機(jī)與錄音您朽,去河邊找鬼狂丝。 笑死,一個(gè)胖子當(dāng)著我的面吹牛哗总,可吹牛的內(nèi)容都是我干的几颜。 我是一名探鬼主播,決...
    沈念sama閱讀 40,320評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼魂奥,長(zhǎng)吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼菠剩!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起耻煤,我...
    開封第一講書人閱讀 39,241評(píng)論 0 276
  • 序言:老撾萬榮一對(duì)情侶失蹤具壮,失蹤者是張志新(化名)和其女友劉穎准颓,沒想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體棺妓,經(jīng)...
    沈念sama閱讀 45,686評(píng)論 1 314
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡攘已,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,878評(píng)論 3 336
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了怜跑。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片样勃。...
    茶點(diǎn)故事閱讀 39,992評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖性芬,靈堂內(nèi)的尸體忽然破棺而出峡眶,到底是詐尸還是另有隱情,我是刑警寧澤植锉,帶...
    沈念sama閱讀 35,715評(píng)論 5 346
  • 正文 年R本政府宣布辫樱,位于F島的核電站,受9級(jí)特大地震影響俊庇,放射性物質(zhì)發(fā)生泄漏狮暑。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,336評(píng)論 3 330
  • 文/蒙蒙 一辉饱、第九天 我趴在偏房一處隱蔽的房頂上張望搬男。 院中可真熱鬧,春花似錦彭沼、人聲如沸缔逛。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,912評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽译株。三九已至,卻和暖如春挺益,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背乘寒。 一陣腳步聲響...
    開封第一講書人閱讀 33,040評(píng)論 1 270
  • 我被黑心中介騙來泰國(guó)打工望众, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人伞辛。 一個(gè)月前我還...
    沈念sama閱讀 48,173評(píng)論 3 370
  • 正文 我出身青樓烂翰,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親蚤氏。 傳聞我的和親對(duì)象是個(gè)殘疾皇子甘耿,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,947評(píng)論 2 355

推薦閱讀更多精彩內(nèi)容