2018-10-22創(chuàng)建tableview模版

#pragma mark - 創(chuàng)建UITableView

- (UITableView*)tableView

{


? ? if(_tableView==nil) {

? ? ? ? CGFloatheight =HEIGHT-naviHeight-34;

? ? ? ? _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, height) style:(UITableViewStylePlain)];

? ? ? ? _tableView.backgroundColor = tableSectionColor;

? ? ? ? _tableView.tableFooterView = [[UIView alloc] init];

? ? ? ? _tableView.separatorInset = UIEdgeInsetsZero;

? ? ? ? _tableView.dataSource=self;

? ? ? ? _tableView.delegate=self;

? ? ? ? [_tableView registerNib:[UINib nibWithNibName:@"sellShowTableViewCell" bundle:nil] forCellReuseIdentifier:@"sellShowTableViewCell"];


? ? }return _tableView;

}


#pragma mark -UITableViewDataSource

- (NSInteger)numberOfSectionsInTableView:(UITableView*)tableView

{

?? ? return1;

}

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

{

? ? return [_listArray count];

}

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

{

? ? _model = [[SaleListModel alloc]init];

? ? staticNSString*cellIndentifier =@"sellShowTableViewCell";//這里的cellID就是cell的xib對(duì)應(yīng)的名稱

? ? sellShowTableViewCell*cell = (sellShowTableViewCell*)[tableViewdequeueReusableCellWithIdentifier:cellIndentifier];

? ? if(nil== cell) {

? ? ? ? NSArray*nib = [[NSBundlemainBundle]loadNibNamed:cellIndentifierowner:selfoptions:nil];

? ? ? ? cell = [nibobjectAtIndex:0];

? ? }

? ? _model= [_listArrayobjectAtIndex:indexPath.row];

? ? _tableView.rowHeight = cell.frame.size.height;

? ? cell.selectionStyle = UITableViewCellSelectionStyleNone;

? ? returncell;


}

#pragma mark -UITableViewDelegate

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

{

? ? return 108;

}

#pragma mark -進(jìn)入出售詳情頁面

- (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath

{

? ? _model= [_listArrayobjectAtIndex:indexPath.row];

? ? [self.delegate goToSellDetils:_model.DetailUrl];


}


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

//? ? if (section ==0) {

//

//? ? ? ? NSArray *arr = [NSArray arrayWithObjects:_cityNameStr,@"交易類型 ",@"篩選 ", nil];

//? ? ? ? _headerView = [[UIView alloc] initWithFrame:CGRectMake(0, naviHeight+realValue(33), WIDTH, realValue(34))];

//

//? ? ? ? for (int i=0; i<3; i++) {

//? ? ? ? ? ? NSString *str = arr[i];

//? ? ? ? ? ? CGFloat bWidth = WIDTH/3;

//? ? ? ? ? ? _typeBtn = [UIButton createButton:CGRectMake(i*bWidth, 0, bWidth, realValue(33)) backgroundColor:RGB(255, 255, 255, 1) title:str target:self action:@selector(typeBtnClick:) font:font(14) titleColor:RGB(60,60, 60,1) tag:i+1];

//? ? ? ? ? ? [_typeBtn setAttributedTitle:[Commen getAttributedStringWithImage:arr[i] imageBounds:CGRectMake(0, 0, realValue(9), realValue(5)) imageName:@"向下箭頭" index:str.length] forState:(UIControlStateNormal)];

//

//? ? ? ? ? ? [_headerView addSubview:_typeBtn];

//? ? ? ? }

//

//? ? }

//? ? return _headerView;

//}

// 返回組頭部view的高度

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

? ? return 0;

}

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容