美文网首页
2018-10-22创建tableview模版

2018-10-22创建tableview模版

作者: 洛天意 | 来源:发表于2018-10-22 09:48 被阅读0次

    #pragma mark - 创建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对应的名称

        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 -进入出售详情页面

    - (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;

    }

    相关文章

      网友评论

          本文标题:2018-10-22创建tableview模版

          本文链接:https://www.haomeiwen.com/subject/oruwzftx.html