tableView section1的类容 跑到 section2上去了

//
// RYStoreHomeViewController.m
// zyouke
//
// Created by ruanyangyang on 16/6/29.
// Copyright © 2016年 ruanyangyang. All rights reserved.
//

import "RYStoreServiceViewController.h"

import "RYStoreServiceInfoCell.h"

import "TDConst.h"

import <SDAutoLayout/UIView+SDAutoLayout.h>

import "HXTagsView.h"

import "RYStoreServiceCell.h"

@interface RYStoreServiceViewController ()<UITableViewDelegate,UITableViewDataSource>
{

NSArray *_titleLabelArray;

}
@property (weak, nonatomic) IBOutlet UIView *btnSegment;
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, weak) UIView *headerContentView;
@property (nonatomic, strong) NSMutableArray *imageInfoArray;
@end

@implementation RYStoreServiceViewController

-(NSMutableArray *)imageInfoArray{

if (!_imageInfoArray) {
    _imageInfoArray=[NSMutableArray array];
}
return _imageInfoArray;

}

  • (void)viewDidLoad {

    [super viewDidLoad];
    [self initFakeData];
    

    // self.view.height=self.viewH;

    self.view.backgroundColor=[UIColor redColor];
    [self.view addSubview:self.tableView];
    [self.tableView setTableFooterView:[[UIView alloc] init]];
    [self inittableviewHeaderView];
    
    

    }

-(void)initFakeData{

self.imageInfoArray=@[@"1.jpg",@"9.jpg",@"8.jpg",@"3.jpg",@"12.jpg",@"6.jpg"].copy;
_titleLabelArray=@[@"作品案例",@"店铺动态"];

// NSMutableArray *marr=[NSMutableArray array];
// for (int i=0; i<self.imageInfoArray.count; i++) {
// UIImageView *imv=[[UIImageView alloc] initWithImage:[UIImage imageNamed:self.imageInfoArray[i]]];
// [marr addObject:imv];
// }
// for (int k=0; k<_titleLabelArray. count; k++) {
//// [[UILabel alloc] init];
// }
}

-(void)inittableviewHeaderView{

UIView *headerContentView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, RYScreenWidth, 100)];
headerContentView.backgroundColor=TDColor(231, 231, 231);

// UILabel *titleLabel =[[UILabel alloc] initWithFrame:CGRectMake(0, 20, RYScreenWidth, 44)];
// titleLabel.textAlignment=NSTextAlignmentLeft;
// titleLabel.text=@"简介";

//单行不滚动 ===============
NSArray *tagAry = @[@"英雄联盟",@"穿越火线",@"地下城与勇士"];
UIView *tableHeaderview=[[UIView alloc] init];
UILabel *titleLable = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 200, 20)];
titleLable.text = @"店家擅长领域";
titleLable.textColor=[UIColor grayColor];
[tableHeaderview addSubview:titleLable];


//多行不滚动 ===============
HXTagsView *tagsView  = [[HXTagsView alloc] initWithFrame:CGRectMake(0, titleLable.frame.origin.y+titleLable.frame.size.height+10, self.view.width, 0)];
tagAry = @[@"企业建站",@"商标注册",@"LOGO设计",@"装修设计",@"淘宝推广",@"广告语",@"微信推广",@"QQ群推广",@"取名",@"网店装修",@"海报设计",@"软文写作",@"视频",@"产品拍摄",@"宣传片"];
tagsView.cornerRadius=12;


//多行不滚动,则计算出全部展示的高度,让maxHeight等于计算出的高度即可,初始化不需要设置高度
[tableHeaderview addSubview:tagsView];
tagsView.type = 0;
[tagsView setTagAry:tagAry delegate:self];
tableHeaderview.size=CGSizeMake(self.view.width, tagsView.height+44);
self.tableView.tableHeaderView=tableHeaderview;

}

-(UITableView *)tableView
{

if (!_tableView) {
    _tableView=[[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
    _tableView.delegate=self;

    _tableView.dataSource=self;
}
return _tableView;

}

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

if (section==0) {
    return 2;
}
return self.imageInfoArray.count;

}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{

return 2;

}

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

static NSString* ID=@"cell";
RYStoreServiceInfoCell *cell=[tableView dequeueReusableCellWithIdentifier:ID];
if (!cell) {
    cell=[[RYStoreServiceInfoCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
    
}

if (indexPath.section==0) {
    cell.textLabel.text=_titleLabelArray[indexPath.row];
}

return cell;

}

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

if (indexPath.section==0) {
    return 44;
}
return 100;

}

  • (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.

    }

-(void)scrollViewDidScroll:(UIScrollView *)scrollView{

CGFloat top=scrollView.contentOffset.y;
if ([self.delgate respondsToSelector:@selector(scrollat:inViewtag:)]) {
    [self.delgate scrollat:top inViewtag:112];
}

}

/*

pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation

  • (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.

    }

*/

@end

查看回复