zoukankan      html  css  js  c++  java
  • iOS开发之----去除tableViewCell分割线的左边间隙,将分割线填满

    -(void)viewDidLayoutSubviews
    {
        if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)])
        {
            [self.tableView setSeparatorInset:UIEdgeInsetsMake(0,0,0,0)];
        }
        
        if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)])
        {
            [self.tableView setLayoutMargins:UIEdgeInsetsMake(0,0,0,0)];
        }
    }
    
    -(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
    {   
        if ([cell respondsToSelector:@selector(setSeparatorInset:)])
        {
            [cell setSeparatorInset:UIEdgeInsetsZero];
        }
        
        if ([cell respondsToSelector:@selector(setLayoutMargins:)])
        {
            [cell setLayoutMargins:UIEdgeInsetsZero];
        }
    }

    1、在- (void)viewDidLoad方法中调用

        [self setUpCellSeparatorInset];

    2、在当前控制器中,实现以下两个方法:

    // 设置cell的分割线左边间距为0

    - (void)setUpCellSeparatorInset

    {

        if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {

            [self.tableView setSeparatorInset:UIEdgeInsetsZero];

        }

        if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) {

            [self.tableView setLayoutMargins:UIEdgeInsetsZero];

        }

    }

    - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath

    {

        if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {

            [cell setSeparatorInset:UIEdgeInsetsZero];

        }

        if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {

            [cell setLayoutMargins:UIEdgeInsetsZero];

        }

    }

  • 相关阅读:
    java内联函数
    jvm垃圾回收
    jvm内存管理
    java进程和线程的区别
    jvm
    简单易学的SSM(Spring+SpringMVC+MyBatis)整合
    Spring之声明式事务
    SpringMVC知识点小结
    Servlet之文件的上传与下载
    java使用字节流和字符流实现文件复制
  • 原文地址:https://www.cnblogs.com/fs-ios/p/4705589.html
Copyright © 2011-2022 走看看