Iphone 是否有人为tableview和tableviewcell使用后台制作应用程序?
像我的问题一样,我只想问一些人,他们制作了一个应用程序,将背景应用于他/她的tableview和tableviewcell。因为我对这些背景有问题。这是我的应用程序图片与问题 我在tableview中使用灰色作为背景,在tableviewcell中使用白色作为背景,我想让所有包含文本的单元格都有白色背景,但我做不到。 这是我的密码Iphone 是否有人为tableview和tableviewcell使用后台制作应用程序?,iphone,uitableview,background,Iphone,Uitableview,Background,像我的问题一样,我只想问一些人,他们制作了一个应用程序,将背景应用于他/她的tableview和tableviewcell。因为我对这些背景有问题。这是我的应用程序图片与问题 我在tableview中使用灰色作为背景,在tableviewcell中使用白色作为背景,我想让所有包含文本的单元格都有白色背景,但我做不到。 这是我的密码 -(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell
-(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]];
}
我的代码有什么问题吗?我已经阅读了德里克给我的链接,我找到了一个可以使用的代码。我决定使用图像作为单元格背景和表格背景。 这是我回答这个问题的代码
-(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
最后,这个问题得到了解决。谢谢大家。。。
(n_n)您已经写过,“我想让所有包含文本的单元格都有白色背景”,您是否需要不包含任何文本的单元格>,以及希望在表中显示多少行。请说清楚。之后我可能会提供帮助。hhmmm…在该表中可能有10行,文本是从数组中填充的,然后你应该在“noofrowsinstruction”返回[yourray count]中写入;请提供你的代码链接,我会更新,因为我没有得到你的问题清楚。还有一件事:这意味着什么?如果([filemodels.fileExpanse compare:@“display”]==0){backgroundView.backgroundColor=[UIColor whiteColor];}否则{backgroundView.backgroundColor=[UIColor whiteColor];}在这两种情况下,输出是相同的。对于您的帮助,thx,数组计数已经添加到“noofrowsinsecution”中,但它仍然像我的照片。但是别担心,我已经找到答案了,我写在答案里