我在我的UITableView中使用自定义标题视图,但只要我开始向下滚动标题消失,而不是像使用默认标题一样保持原样。而且它不会从屏幕上滚动,只是完全消失。 viewForHeaderInSection仍然被调用,但我的自定义标题视图的drawRect方法不是。我究竟做错了什么?下面是一些代码...viewForHeaderInSection滚动时消失
我的UITableView数据源...
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
HeaderView* headerView = [[[HeaderView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 40.0f)] autorelease];
return headerView;
}
...和我的自定义标题...
-(void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(context, 115.0f, 125.0f, 133.0f, 0.5f);
CGContextFillRect(context, CGRectMake(0.0f, 0.0f, 320.0f, 40.0f));
}
我发现了一个解决方案,我添加了我的自定义标题视图作为基本UIVIew的子视图(我从viewForHeaderInSection返回),它起到了魅力。似乎有点愚蠢,我的观点(UIVIew分类)不会表现出来。好吧。 – rob5408 2010-04-24 23:37:09
奇数,但它确实有效。 – 2010-11-04 11:53:55