zoukankan      html  css  js  c++  java
  • 如何处理UIVIew addsubview 不显示subview

    老代码: addsubview不显示uilabel
    -(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
    {
        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0,0,tableView.frame.size.width,50)];
        UILabel *label=[[UILabel new]initWithFrame:CGRectMake(0, 0 ,200, 50)];
    
        label.text=@"加载更多...";
        label.textColor=[UserSetting getIntance].titleColor;
        label.backgroundColor=[UserSetting getIntance].titleColor;
        [view addSubview:label];
         [view setBackgroundColor:[UserSetting getIntance].mainColor];
        return view;
    }
    原因在于:addsubview 没有使 UILabel的大小生效
    需要在addsuview后面再赋值frame.
    新代码如下
    -(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
    {
        UIView *view = [[UIView alloc]     initWithFrame:CGRectMake(0,0,tableView.frame.size.width,50)];
        UILabel *label=[[UILabel new]init];
    
        label.text=@"加载更多...";
        label.textColor=[UserSetting getIntance].titleColor;
        label.backgroundColor=[UserSetting getIntance].titleColor;
        [view addSubview:label];
        label.frame=CGRectMake(0, 0 ,200, 50);
        [view setBackgroundColor:[UserSetting getIntance].mainColor];
        return view;
    }
    

      

  • 相关阅读:
    ubuntu 启动 卡死在 clean ... file ... blocks
    realsense opencv example 运行时无显示退出
    realsense example 最简单编译
    python内置方法
    接口自动化测试框架
    git使用问题
    自动化测试工具原理
    四层协议网络传输
    字符串反转
    排除链接数性能瓶颈
  • 原文地址:https://www.cnblogs.com/Zoes/p/5117587.html
Copyright © 2011-2022 走看看