• 自定义控件


    //
    //  MyTableViewCell.m
    //  MyTableCell
    //
    //  Created by apple on 14-8-6.
    //  Copyright (c) 2014年 apple. All rights reserved.
    //
    
    #import "MyTableViewCell.h"
    
    @implementation MyTableViewCell
    
    - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
    {
        self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
        if (self) {
            _label=[[UILabel alloc]initWithFrame:CGRectMake(230, 0, 110, 30)];
    //        _label.backgroundColor=[UIColor redColor];
            _label.font=[UIFont systemFontOfSize:13];
            [self.contentView addSubview:_label];
    //
    //        self.textLabel.backgroundColor = [UIColor clearColor];
        }
        return self;
    }
    
    - (void)awakeFromNib
    {
        // Initialization code
    }
    
    - (void)setSelected:(BOOL)selected animated:(BOOL)animated
    {
        [super setSelected:selected animated:animated];
    
        // Configure the view for the selected state
    }
    
    - (void)layoutSubviews
    {
        [super layoutSubviews];
        
    //        self.textLabel.frame = CGRectMake(250, 0, 100, 40);
    }
    
    @end
    
    
    
    
    //
    //  ViewController.m
    //  MyTableCell
    //
    //  Created by apple on 14-8-6.
    //  Copyright (c) 2014年 apple. All rights reserved.
    //
    
    #import "ViewController.h"
    #import "MyTableViewCell.h"
    @interface ViewController ()<UITableViewDataSource,UITableViewDelegate>
    {
        UITableView *_tableView;
    }
    
    @end
    
    @implementation ViewController
                
    - (void)viewDidLoad {
        [super viewDidLoad];
        
        _tableView=[[UITableView alloc]initWithFrame:CGRectMake(0, 20, 320, 400) style:UITableViewStylePlain];
        _tableView.delegate=self;
        _tableView.dataSource=self;
        [self.view addSubview:_tableView];
        
        [_tableView registerClass:[MyTableViewCell class] forCellReuseIdentifier:@"cell"];
    }
    
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {
        return 30;
    }
    
    -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        MyTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    //    if (cell==nil)
    //    {
    //        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    //    }
    //
        cell.label.text=@"liSi";
    
        cell.textLabel.text=@"2222";
        return cell;
        
    }
    
    - (void)didReceiveMemoryWarning {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
    
    @end
  • 相关阅读:
    css
    博客目录
    macOS下psql客户端中文乱码问题
    PostgreSQL dblink的使用
    error: RPC failed; curl 56 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 60
    mac中环境变量配置
    PostgreSQL Copy 命令
    Linux下rz命令和sz命令使用方法
    Tmux 使用教程
    create_time和update_time自动填写
  • 原文地址:https://www.cnblogs.com/lidongq/p/3895792.html
Copyright © 2020-2023  润新知