我在我的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