-- tableView的cell背景设置为透明时,文字会重叠在一起 -
来源:互联网 发布:淘宝团购提醒在哪里 编辑:程序博客网 时间:2024/06/10 18:06
-- tableView的cell背景设置为透明时,文字会重叠在一起 -
http://www.cocoachina.com/bbs/simple/?t30484.html
tableView的cell背景设置为透明时,文字会重叠在一起
我把tableView里面的背景色设置为clearColor时,如果cell的行数超过一页的话,拖动时,发现里面的文字会出现重影,本来已经被刷新的文字没有消失,和新的显示的文字重叠在一起。有没有什么办法去掉以前的文字?
ajuncgpcqz2010-08-27 09:31大家没碰到类似的问题吗
buan2010-08-27 10:30static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier";
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:SimpleTableIdentifier];
NSInteger section=[indexPath section];
if(cell==nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"SimpleTableIdentifiers"] autorelease];
}
以前我也碰到过这样的情况,你tableView里面肯定还有其他的控件吧
ajuncgpcqz2010-08-27 15:22是啊,里面有几个label和button
不过问题我已经解决了,解决方法如下:
-(UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *RootViewControllerCell=@"RootViewControllerCell";
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:RootViewControllerCell];
if(cell==nil)
{
cell=[[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:RootViewControllerCell] autorelease];
CGRect textValueRect=CGRectMake(90, 15, 150, 40);
UILabel *textValue=[[UILabel alloc]initWithFrame:textValueRect];
textValue.textColor=[UIColor whiteColor];
textValue.tag=NameValueTag;
textValue.backgroundColor=[UIColor clearColor];
textValue.font=[UIFont boldSystemFontOfSize:18];
[cell.contentView addSubview:textValue];
[textValue release];
}
NSUInteger row=[indexPath row];
UILabel *textName=(UILabel *)[cell.contentView viewWithTag:NameValueTag];
textName.text=[listData objectAtIndex:row];
return cell;
}
要把label的定义部份放在if里面,这样就不会重复刷新了
r78z
- -- tableView的cell背景设置为透明时,文字会重叠在一起 -
- cell的文字会重叠在一起
- 关于使用了透明文字背景后,文字不能刷新而重叠在一起的问题
- 关于使用了透明文字背景后,文字不能刷新而重叠在一起的问题
- 标签背景透明以及文字重叠问题
- tableview——设置cell的文字居中和透明度
- 设置背景为透明
- 将图片的背景设置为透明
- 设置flash的背景为透明
- 设置静态文本框的背景为透明
- 设置Tlabel的背景为透明
- iOS - 设置NavigationBar的背景为透明
- UITableView为group时设置背景透明
- 创建Bitmap时设置背景为透明
- ios6,tableView设置背景透明无效
- tableview 背景设置为半透明
- 解决当静态文本或编辑框等控件设置为透明后文字重叠问题
- IOS 取消TableView点击Cell时的色背景
- 仿百度、Google的suggest特效功能,源码分析
- mysql优化必备25条
- C++中的空类,编译器默认可以产生哪些成员函数
- Openfire框架发生常见的异常
- 黑马程序员-继承 子类的实例化和final关键字*
- -- tableView的cell背景设置为透明时,文字会重叠在一起 -
- 经典SQL语句大全
- C专家编程(九)
- 加快VisualStudio的开发速度--VS的一些开发技巧
- linux编程相关
- 多目录多文件[1] 简单Makefile
- Hibernate ThreadLocal
- 学习LOWORD、 HIWORD、LOBYTE、HIBYTE
- 什么是Core Dump?