• 关于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

  • 相关阅读:
    富文本的一般处理方式,document.getElementById('富文本的ID').contentWindow.document.body.innerHTML = '%s'" %(content)
    本地搭建Jenkins
    if __name__ == '__main__'是什么意思?如何理解?看到一个很有用的解答
    关于执行webdriver.Chrome; 报错WebDriverException: Message: unknown error: Element is not clickable at point (1085, 103)
    【转载】学习总结——接口测试基础
    fiddler使用——配置抓取https,出现提示“禁用解密”“单击配置”
    算法(二叉树-矩阵-堆排序)
    算法(递归)---写的很乱
    ES6高级技巧(二)
    ES6高级使用技巧(reduce,filter篇)
  • 原文地址:https://www.cnblogs.com/riskyer/p/3253852.html
Copyright © 2020-2023  润新知