2010-06-03 40 views
1

我的UITableViewCell在它不應該是透明的時候是透明的。我的表格視圖有一個背景顏色,它通過表格單元顯示,即使它們應該是不透明的。我不確定這是爲什麼。UITableViewCell在不應該是透明的時候是透明的

相關代碼:

UITableViewCell *cell = [table dequeueReusableCellWithIdentifier:emptyIdentifier]; 
    if (cell == nil) { 
     cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:emptyIdentifier] autorelease]; 
    } 

    cell.textLabel.text = @"Empty"; 
    cell.textLabel.textAlignment = UITextAlignmentCenter; 
    cell.textLabel.backgroundColor = [UIColor whiteColor]; 
    return cell; 

回答

0

我相信這是因爲CGRectZero的。 嘗試使用initWithStyle並使用其中一種系統樣式。 http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UITableViewCell_Class/Reference/Reference.html#//apple_ref/occ/instm/UITableViewCell/initWithStyle:reuseIdentifier

不過,initWithFrame已被棄用。

+0

沒有幫助。其實我是從initwithstyle開始的,但那不起作用,所以我回到了一些較老的代碼,看看它是否有效。無論如何,它似乎並沒有影響它。 – 2010-06-03 03:22:10

+0

然後添加cell.backgroundcolor = [UIColor clearColor]; – Mugunth 2010-06-03 03:32:54

+0

不做任何事情。你的意思是whiteColor?可悲的是,這也不起作用。 一般來說,整個文本標籤都搞砸了,並且不遵循常規的子視圖規則或其他內容。我試着將backgroundView.backgroundColor設置爲白色,並且最終會將邊框着色爲白色,但標籤邊界內的所有內容都像窗口一樣起作用,從而揭示底下的表格背景。 我基本上通過不處理tablecell的textLabel來繞過整個情況,並添加了我自己的UILabel。雖然非常愚蠢和hackish。沒有意義。 – 2010-06-03 03:45:03

0

在IB中,單擊uitableviewcell,然後選中「剪輯子視圖」屬性。

相關問題