zoukankan      html  css  js  c++  java
  • ios-表视图-demo1

    //
    //  RootViewController.m
    //  uitableview
    //
    //  Created by  liyang on 14-4-27.
    //  Copyright (c) 2014年 liyang. All rights reserved.
    //
    
    #import "RootViewController.h"
    
    @interface RootViewController ()
    
    @end
    
    @implementation RootViewController
    
    - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
    {
        self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
        if (self) {
            // Custom initialization
        }
        return self;
    }
    -(void)loadView{
        UIView *view=[[UIView alloc]initWithFrame:[[UIScreen mainScreen] applicationFrame]];
        self.view=view;
        _uitableview=[[UITableView alloc]initWithFrame:view.bounds style:UITableViewStylePlain];
        _uitableview.dataSource=self;//设置数据源代理
        _uitableview.rowHeight=45;//行高,默认的44
        UIImageView*imageview=  [[UIImageView alloc]initWithFrame:self.view.bounds];
        imageview.image=[UIImage imageNamed:@"IMG_0410"];//设置背景图片
        _uitableview.backgroundView=imageview;
        _fontarry=[UIFont familyNames];
        //设置表视图的分割线
        //_uitableview.separatorColor=[UIColor grayColor];
        //_uitableview.separatorStyle=UITableViewCellSeparatorStyleNone;
        //设置头部视图(上面加上各种子视图)
        UIView* headerview=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 100)];
        headerview.backgroundColor=[UIColor purpleColor];
        _uitableview.tableHeaderView=headerview;
        //设置尾部视图(上面加上各种子视图)
        UIView* footerview=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 100)];
        footerview.backgroundColor=[UIColor yellowColor];
        _uitableview.tableFooterView=footerview;
        [self.view addSubview:_uitableview];
    }
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        // Do any additional setup after loading the view.
    }
    
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
        return [_fontarry count];
    }
    
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
        NSString *cellindentifier=@"cellidentifier";
        UITableViewCell* cell=[tableView dequeueReusableCellWithIdentifier:cellindentifier];
        if (cell==nil) {
            cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellindentifier];
        }
        NSString *fontname=_fontarry[indexPath.row];
        NSLog(@"%d",indexPath.row);
        cell.textLabel.text=fontname;
        cell.textLabel.font=[UIFont fontWithName:fontname size:14];
        return cell;
    
    }
    //页眉这2个和后面的自定义是相互冲突的,两者取其一
    - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
        return @"liyangstart";
    }
    //页脚
    - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section{
        return @"liyangend";
    }
    
    - (void)didReceiveMemoryWarning
    {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
    
    
    
    @end
     
    1.这里只记录一些学习笔记 2.这里只记录一些学习心得,如果心得方向有错,请留言 2.这里只记录一些日记(只为提升英语,暂时有点忙,等转行了开始写)
  • 相关阅读:
    【转载】数据杂谈
    【转载】行走在网格之间:微博用户关系模型
    【转载】TalkingData首席金融行业专家鲍忠铁:18亿数据解读移动互联网
    【转载】大数据架构和模式
    【转载】Deep Learning(深度学习)学习笔记整理
    【转载】如何组建一支优秀的数据分析团队?
    【转载】Hadoop可视化分析利器之Hue
    【转载】关于烂代码的那些事
    【转载】6个用好大数据的秘诀
    【转载】如何一步步从数据产品菜鸟走到骨干数据产品
  • 原文地址:https://www.cnblogs.com/liyang31tg/p/3694911.html
Copyright © 2011-2022 走看看