有人使用tableview和tableviewcell的背景制作应用程序吗? [英] is there somebody who made an application using background for tableview and tableviewcell?

查看:56
本文介绍了有人使用tableview和tableviewcell的背景制作应用程序吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

就像我的问题一样,我只想问一个制作了使用background作为他/她的tableview和tableviewcell的应用程序的人.因为我有那些背景问题.这是我的问题的应用程序照片

like my question, i just want to ask somebody who made an application that use background for his/her tableview and tableviewcell. Cause i have a problem with those background. Here is my app pic with the problem

我在tableview中使用graycolor作为背景,在tableviewcell中使用whitecolor作为背景,我想使包含文本的所有单元格都具有白色背景,但是我无法做到这一点. 这是我的代码

i use graycolor for background in tableview and whitecolor for background in tableviewcell, i want to make all cell that containt a text have a whitecolor background, but i can't do it. here's my code

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
UIView* backgroundView = [ [ [ UIView alloc ] initWithFrame:CGRectZero ] autorelease ];

//--new color code--
backgroundView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"celltable_root.png"]];

cell.backgroundView = backgroundView;
for ( UIView* view in cell.contentView.subviews ) 
{
    if(_segmentedControl.selectedSegmentIndex == 0){
        FileModel *filemodels = [_filemodels objectAtIndex:indexPath.row];
        if([filemodels.fileExpanse compare:@"display"]==0){

            backgroundView.backgroundColor = [UIColor whiteColor];


        }else{
            backgroundView.backgroundColor = [UIColor whiteColor];

        }
    }

    view.backgroundColor = [ UIColor clearColor]; //set cell background

}

    [[self tableView] setBackgroundColor:[UIColor grayColor]]; 

}

我的代码有问题吗?

推荐答案

我已经阅读了Derek给我的链接,我找到了可以使用的代码.我决定将图像用于单元格背景和表格背景. 这是我的代码来回答这个问题

i already read the link that Derek gave to me, and i found a code that i can use. I've decided to use image for cell background and table background. and this is my code to answer this question

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{

    if(_segmentedControl.selectedSegmentIndex == 0){
        FileModel *filemodels = [_filemodels objectAtIndex:indexPath.row];
        if([filemodels.fileExpanse compare:@"display"]==0){

            ((UIImageView *)cell.backgroundView).image = [UIImage imageNamed:@"whiteColor.png"];

        }else{
            ((UIImageView *)cell.backgroundView).image = [UIImage imageNamed:@"whiteColor.png"];

        }
    }

    [[self tableView] setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"grayColor.png"]]]; //tableview background using image

}

我添加了

[[self tableView] setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"grayColor.png"]]]; //tableview background using image

进入viewDidLoad方法,最后...解决了这个问题.谢谢大家... (n_n)

into viewDidLoad method, and finally...this problem is solved. Thx everyone... (n_n)

这篇关于有人使用tableview和tableviewcell的背景制作应用程序吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆