解析iOS開發(fā)基礎(chǔ) UITableView
作者:佚名
本文介紹的是解析iOS開發(fā)基礎(chǔ) UITableView,內(nèi)容基本是是用代碼實(shí)現(xiàn)的,不多說,先來看內(nèi)容。
iOS開發(fā)基礎(chǔ) UITableView是本文要介紹的內(nèi)容,本文是基于代碼實(shí)現(xiàn)的,不多說,先來看內(nèi)容,實(shí)現(xiàn)UITableView的Controller需要實(shí)現(xiàn) < UITableViewDataSource, UITableViewDelegate > 這兩個(gè)代理,具體就是要實(shí)現(xiàn)以下兩個(gè)方法:
- - (NSInteger)tableView:(UITableView *)tableView
- numberOfRowsInSection:(NSInteger)section{
- return [model getRowCount];
- }
- //返回UITableView的行數(shù)
- - (UITableViewCell *)tableView:(UITableView *)tableView
- cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- static NSString *CellIdentifier = @”Cell”;
- UITableViewCell *cell = [tableView
- dequeueReusableCellWithIdentifier:CellIdentifier];
- if (cell == nil) {
- cell = [[[UITableViewCell alloc]
- initWithFrame:CGRectZero
- reuseIdentifier:CellIdentifier] autorelease];
- }
- NSUInteger row = [indexPath row];
- cell.textLabel.text = [model getNameAtIndex:row];
- return cell;
- }
- //呈現(xiàn)UITableView的每一個(gè)Cell
小結(jié):關(guān)于解析iOS開發(fā)基礎(chǔ) UITableView的內(nèi)容介紹完了,希望本文對(duì)你有所幫助!
責(zé)任編輯:zhaolei
來源:
互聯(lián)網(wǎng)