• iOS UI 07 uitableviewi2


    //

    //  RootViewController.m

    //  UI - 08 UItableview

    //

    //  Created by dllo on 15/11/18.

    //  Copyright (c) 2015 dllo. All rights reserved.

    //


    #import "RootViewController.h"


    @interface RootViewController () <UITableViewDelegate, UITableViewDataSource>


    @end


    @implementation RootViewController


    - (void)viewDidLoad {

        [super viewDidLoad];

        self.view.backgroundColor = [UIColor whiteColor];

        

        

        UITableView *table = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStylePlain];

        table.delegate = self;

        table.dataSource = self ;

        [self.view addSubview:table];

        [table release];

        

        

        

        UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 100)] autorelease];

        view.backgroundColor = [UIColor greenColor];

        table.tableHeaderView = view;

        

        

        

        

        

        

        // Do any additional setup after loading the view.

    }

    //行数

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

    {

        return 5;

    }


    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

    {

        

        //static ,只在编译的时候执行一次,以后不再执行

       static NSString *cellStr = @"cell";

    //    UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle: UITableViewCellStyleDefault reuseIdentifier:cellStr];

    //    NSLog(@"%d", __LINE__);

        

        //到重用池中取cell, 若有直接用,若无创建新的cell

        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellStr];

        if (nil == cell) {

            cell = [[[UITableViewCell alloc] initWithStyle:    UITableViewCellStyleValue1 reuseIdentifier:cellStr] autorelease];

            cell.textLabel.text = @"泰勒-斯威夫特";

            cell.imageView.image = [UIImage imageNamed:@"1.png"];

            cell.detailTextLabel.text = @"

  • 相关阅读:
    retofit、ButterKnite
    [iOS笔记]Swift中的Optional类型
    [iOS笔记] 网络通信安全与证书
    [iOS]ReactiveCocoa playground配置
    NAT学习笔记
    [iOS学习笔记]runloop runMode方法调研
    Python 装饰器简单介绍
    cookie实现自动登陆原理
    iOS开发添加Reveal工具
    【iOS Programming: The Big Nerd Ranch Guide】【笔记】2
  • 原文地址:https://www.cnblogs.com/yuhaojishuboke/p/5043083.html
Copyright © 2020-2023  润新知