zoukankan      html  css  js  c++  java
  • 关于tableView的简单实例

    关于tableCell选中颜色

    //无色

    cell.selectionStyle = UITableViewCellSelectionStyleNone;


    //蓝色
    cell.selectionStyle = UITableViewCellSelectionStyleBlue;


    //灰色
    cell.selectionStyle = UITableViewCellSelectionStyleGray;


     

    设置tableViewCell间的分割线的颜色

    [theTableView setSeparatorColor:[UIColor xxxx ]];


     

    自定义UITableViewCell选中时背景

        cell.selectedBackgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cellart.png"]] autorelease]; 
        还有字体颜色 
        cell.textLabel.highlightedTextColor = [UIColor xxxcolor];  [cell.textLabel setTextColor:color];//设置cell的字体的颜色


     

    改变UITableViewCell选中时背景色:

     

       cell.selectedBackgroundView = [[[UIView alloc] initWithFrame:cell.frame] autorelease];
       cell.selectedBackgroundView.backgroundColor = [UIColor xxxxxx];

     

    我自己的一个实例:

    #import "AndyViewController.h"


    @interfaceAndyViewController ()


    @end


    @implementation AndyViewController


    - (void)viewDidLoad

    {

        [superviewDidLoad];

        NSArray *array=[[[NSArrayalloc] initWithObjects:@"monday",@"tunesday",@"thursday",@"firday",@"staturday",@"sunday",nil] autorelease];

        self.listdata=array;

    // Do any additional setup after loading the view, typically from a nib.

    }


    - (void)didReceiveMemoryWarning

    {

        [superdidReceiveMemoryWarning];

        // Dispose of any resources that can be recreated.

    }

    -(void)dealloc

    {

        [super dealloc];

        [_listdatarelease];

        [_tableViewrelease];

    }


    #pragma UITableViewDataSourc delegate

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

    {

        return [self.listdata count];

    }

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

    {

        staticNSString *identifier=@"SimpleTableIdentifier";

        

        UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:identifier];

        if(cell==nil)

        {

            cell=[[UITableViewCellalloc] initWithStyle:UITableViewCellStyleDefault

                    reuseIdentifier:identifier];

            

        }

    cell.imageView.image=[UIImageimageNamed:@"star.png"];

    cell.textLabel.textColor=[UIColorredColor];

    cell.textLabel.text=[self.listdataobjectAtIndex:indexPath.row];

        cell.selectionStyle=UITableViewCellSelectionStyleNone;

        return cell;

    }


    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

    {

        return 90;

    }


    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

    {

        NSString *message=[self.listdata objectAtIndex:indexPath.row];

        UIAlertView *alert=[[UIAlertViewalloc] initWithTitle:@"you have selected "message:message delegate:selfcancelButtonTitle:@"取消"otherButtonTitles: nil];

        [alert show];

    }

    @end

  • 相关阅读:
    网络测量中基于Sketch方法的简单介绍
    Reading SBAR SDN flow-Based monitoring and Application Recognition
    Reading Meticulous Measurement of Control Packets in SDN
    Reading SketchVisor Robust Network Measurement for Sofeware Packet Processing
    ovs加dpdk在日志中查看更多运行细节的方法
    后缀数组
    (转载)LCA问题的Tarjan算法
    Codeforces Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) A. Checking the Calendar(水题)
    Vijos 1816统计数字(计数排序)
    卡特兰数
  • 原文地址:https://www.cnblogs.com/riskyer/p/3253852.html
Copyright © 2011-2022 走看看