zoukankan      html  css  js  c++  java
  • 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 = @"

  • 相关阅读:
    爬虫-某游戏交易网站商品信息爬取
    爬虫-淘宝selenium模拟登录取cookie
    设计模式
    xadmin安装2
    MySQL用户授权 和 bin-log日志 详解和实战
    用Redis实现分布式锁 与 实现任务队列
    基于H5的微信支付开发详解
    静态资源文件自动压缩并替换成压缩版本(大型网站优化技术)
    IP、TCP和DNS与HTTP的密切关系
    减少HTTP请求之将图片转成二进制并生成Base64编码,可以在网页中通过url查看图片(大型网站优化技术)
  • 原文地址:https://www.cnblogs.com/yuhaojishuboke/p/5043083.html
Copyright © 2011-2022 走看看