美文网首页iOSiOS Developer程序员
 第一次在简书上写文章

 第一次在简书上写文章

作者: 码农冰冰 | 来源:发表于2016-11-18 11:35 被阅读204次
42C527D6-90B0-4858-8EE5-6C9005EC3226.png 32358BF9-7A7D-4FFD-8D70-46CB4F129D2B.png

代码实现:

  • cellForRowAtIndexPath方法:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    NSLog(@"11111111111111");

    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];

        cell.backgroundColor =[UIColor clearColor];
        UIView *selectedBackgroundView = [[UIView alloc] initWithFrame:cell.frame];
        selectedBackgroundView.backgroundColor = [UIColor whiteColor];
        cell.selectedBackgroundView = selectedBackgroundView;   
        // 左侧示意条
        UIView *liner = [[UIView alloc] initWithFrame: CGRectMake(0, 0, 2, 40)];
        liner.backgroundColor = [UIColor orangeColor];
        [selectedBackgroundView addSubview:liner];
    }
    cell.textLabel.text=[NSString stringWithFormat:@"第%ld个",indexPath.row];
        return cell; 
}
  • 代理方法:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{    
    NSLog(@"22222222222222");
    if (_isRelate==YES) {
            [tableView selectRowAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0] animated:YES scrollPosition:UITableViewScrollPositionMiddle];
    }
}
- (void)tableView:(UITableView *)tableView didEndDisplayingCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath*)indexPath NS_AVAILABLE_IOS(6_0){
    NSLog(@"33333333333333");
    _isRelate=NO;
}

当然也有很多其他的实现方式就不多做介绍了。

相关文章

  • 开篇

    第一次在简书上写文章

  • 第一篇文章该给你

    第一次在简书上写文章,试试看。

  • 2018-08-09

    在简书上写文章

  • markdown在简书上写文章

    1.在网上找了些怎么解说文字有灰褐色背景编辑都没有找到具体操作:1>.先在编辑那一行点击 “return ”键2...

  • 新人报道

    第一次在简书上写文章,望各位简友抽时间瞅瞅,给个建议!谢谢大家!

  • 开始动笔

    开始在简书上写文章咯。

  • 第一次在简书上写文章

    成为值得信赖的人成为诚实的人积极地学习不贬抑他人追求自身的最佳 这五行字是我在修读面向对象分析与设计这门选修课上老...

  •  第一次在简书上写文章

    匆匆岁月 学习iOS已经很久了,总想记录点什么,总被我的借口一次一次的给挡在门外了,想着没事看个电视剧;想着没事对...

  • 第一次在简书上写文章

    这是我第一次在简书上写文章,我只是觉得最近有太多的话很想说,就是一直说不出口,也许通过写作可以让我平静一点吧。...

  • 第一次在简书上写文章

    今天老师给我们推荐了一个软件,就是简书。老师说:"这个软件很好,可以在上面写文章,也可以学习别人是怎么写的,第一次...

网友评论

    本文标题: 第一次在简书上写文章

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