iOS tableView头部不动,cell滑动

思路:

            1、创建一个样式为plain的tableView;

            2、返回多个section;

            3、返回多个row;

            4、设置tableHeadView的背景色(解决方法:在  -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section  中创建一个UI View,并设置其背景色,再在其添加UILabel,返回UI View对象);

代码:

_deviceStateTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 80, UISCREEN_WIDTH, UISCREEN_HEIGHT-64) style:UITableViewStylePlain];
_deviceStateTableView.delegate = self;
_deviceStateTableView.dataSource = self;
_deviceStateTableView.backgroundColor = [UIColor  clearColor];
[self.view  addSubview:_deviceStateTableView];



-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return  10;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return  10;
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    UIView *view = [[UIView  alloc]initWithFrame:CGRectMake(0, 0, UISCREEN_WIDTH, 30)];
    view.backgroundColor = self.view.backgroundColor;

    UILabel *time = [[UILabel  alloc]initWithFrame:CGRectMake(10, 0, UISCREEN_WIDTH, 30)];
    time.text = [[[Bdx_note  getDeviceArr]objectAtIndex:section]objectForKey:@"time"];
    [view addSubview:time];
    return view;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值