Strange behaviour of Subclassed UITableViewCell when selected - ios

I have a subclass of UITableViewCell, which has a number of UILabels, a UIImageView and a UIView in it.
I have the cell set to highlight blue when it is selected. The strange behaviour that I am observing is the UIView that I have added as a property of the UITableViewCell subclass disappears when the cell is selected, and returns when the cell is deselected. This UIView is just an empty view with a background color, so it is possible that the background color is being set to clear when the table view cell is selected. None of the other elements are effected.
Does anyone have an idea what is happening here, and how to fix it?

Related

With DarkMode the ContentView of a cell is not selected on touch, only the AccessoryView

As per title, with darkMode the selection of a grouped cell is not working as expected: the ContentView of a cell is not selected on touch, only the AccessoryView. Everything works fine on the LightMode.
I have changed the background color of both the cell and its content view to Default (Table Cell Grouped Background Color) in the StoryBoard.
If it can help, the background color of the accessoryView is made equal to the background color of the Content View in the willDisplay cell function
favouriteCell.contentView.superview?.backgroundColor = favouriteCell.contentView.backgroundColor
The problem is due to a bug: the app doesn't register background color changes of the cell if done in the storyboard

UITableViewCell Did Selected the subviews backgroundcolor are changed

The view on the right bottom added at the imageview , when i select the cell, the bgcolor will changed ,how avoid this happen?
thanks.
Image Before Selection
Image after Selection
Change your cell's selection style to none either programmatically or from storyboard.
If you want to do it programmatically, you can may write this code in your cell's awakeFromNib method.
cell.selectionStyle = .none
This will resolve your issue.

iOS - Get rid of UITableViewCell selection background color change

When I select a cell in my table, it highlights it in gray. I don't want it to highlight it at all. However, it still needs to be selectable in general because it contains buttons.
If I try to set the selectedBackgroundView of the cell (or set the backgroundColor of the cell when selected), this will obscure the cell separator.
Try to set cell's selectionStyle property to .None - this property controls the color cell changes to when highlighted or selected.
In Interface Builder, you can set your table view to have Single Selection, while your cells can have the .None selection style, as Vladimir states.

Display label in UITableview cell When its visible in Ios

I am new to iOS. I need to show the Label in timeDelay in UITableViewCell only when its visible?
Create a custom UITableView cell. In your cellForRowIndexPath, call the function performSelectorWithDelay which will show your UILabel.
When the cellForRowIndexPath is called, it's pretty certain that the cell will now be shown.

Don't highlight UIImageViews in UICollectionViewCell

I have a subclass of UICollectionViewCell that contains some UIImageViews that have highlighted image states. I do not want these images to become highlighted when the user taps on the collection view cell. The highlighted states are set in code based on other factors.
How can I get the cells to not set the image views to highlighted when the cell is selected?
Override setHighlighted in your UICollectionViewCell class:
-(void)setHighlighted:(BOOL)highlighted{
[super setHighlighted:highlighted];
self.imageView.highlighted = NO;
}

Resources