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 = @"

转载于:https://www.cnblogs.com/yuhaojishuboke/p/5043083.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值