正在將iOS6應用轉換爲iOS7,他們正在使用它來設置分組的tableview樣式。在iOS7中,cell.selectedBackgroundView未顯示
cell.backgroundView = aView;
cell.selectedBackgroundView = bView;
當應用程序加載時,它正確地加載backgroundView,但是當我點擊單元格中的selectedBackgroundView不再iOS7工作。點擊選擇單元格,以便工作,但selectBackgroundView只是不顯示。
有什麼建議嗎?我唯一能想到的就是不使用selectedBackgroundView,並且每次選擇和取消選中時,都會在單元格中添加和刪除子視圖。
/// UPDATE ///
把這個在我的cellForRowAtIndex和仍然沒有不工作。
UIView *bgColorView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
bgColorView.backgroundColor = [UIColor colorWithRed:(76.0/255.0) green:(161.0/255.0) blue:(255.0/255.0) alpha:1.0]; // perfect color suggested by @mohamadHafez
bgColorView.layer.masksToBounds = YES;
cell.selectedBackgroundView = bgColorView;
////更新2 ///////////
如果我把這個在我的cellforRowAtIndex
cell.selectedBackgroundView = nil;
cell.backgroundView = nil;
UIView *bgColorView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
bgColorView.backgroundColor = [UIColor colorWithRed:(76.0/255.0) green:(161.0/255.0) blue:(255.0/255.0) alpha:1.0]; // perfect color suggested by @mohamadHafez
bgColorView.layer.masksToBounds = YES;
cell.selectedBackgroundView = bgColorView;
UIView *bgSColorView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
bgSColorView.backgroundColor = [UIColor colorWithRed:(106.0/255.0) green:(201.0/255.0) blue:(255.0/255.0) alpha:1.0]; // perfect color suggested by @mohamadHafez
bgSColorView.layer.masksToBounds = YES;
cell.backgroundView = bgSColorView;
兩個展會cell.background爲bgSColorView ,但是當我單擊單元格時沒有任何反應(又名selectedBackgroundView不顯示?爲什麼選擇的背景視圖不被提升和顯示?
/// UPDATE 3 //// 我把t他在我的setSelectin:animation:爲我的單元格類(刪除了上面的東西)。
UIView *bgColorView = [[UIView alloc] init];
bgColorView.backgroundColor = [UIColor colorWithRed:(76.0/255.0) green:(161.0/255.0) blue:(255.0/255.0) alpha:1.0]; // perfect color suggested by @mohamadHafez
bgColorView.layer.masksToBounds = YES;
self.selectedBackgroundView = bgColorView;
UIView *bgSColorView = [[UIView alloc] init];
bgSColorView.backgroundColor = [UIColor colorWithRed:(106.0/255.0) green:(201.0/255.0) blue:(25.0/255.0) alpha:1.0]; // perfect color suggested by @mohamadHafez
bgSColorView.layer.masksToBounds = YES;
self.backgroundView = bgSColorView;
[super setSelected:selected animated:animated];
現在看來正確,因爲我想要它。但第二個我點擊任何單元格BOOOM的背景和selectionBackgroundView即時刪除,消失。
在7蘋果確實與細胞背景是什麼。他們在背景的「上方」滑動了一層不透明的白色圖層,並且它只會在cell * cellForCowForTowAtIndexPath(在XIB中不足)執行setBackgroundColor時纔會消失。不確定這可能會如何影響背景圖片,但您可能需要設置背景顏色以清除。 –
你是否繼承了'UITableViewCell'? – sooper
是的,它被分類。但我只是改變了它的子類UITableViewCell,仍然是相同的結果。 – jdog