UITableViewCell selection behaviour changes when selectedBackgroundView is set - ios

I have a UITableViewCell which is loaded from a xib, with a handful of labels and image views. I notice that when the .selectedBackgroundView property is set (in -awakeFromNib), interaction with the cell is only possible when touching on the labels or image views within the cell.
Trying to touch any blank space in the cell does nothing. Not setting .selectedBackgroundView returns the behaviour to normal.
Does anyone have a fix for this? (Mine currently is to place an empty UILabel over the entire contents of my cell)

Related

Contained UITableView's Height always 44.0

I am trying to create a button like UIControl that looks like the standard UITableViewCell and support the CellStyles of Value1, Default and Subtitle.
I did try simply creating a UITableViewCell and adding it as a SubView of my UIControl but unsurprisingly the cells don't behave as expected when not in a UITableView.
So I now have a table in my UIControl that has a custom Table DataSource that is hardcoded to only one row.
When I create the cell I populate the text values of the TextLabel and DetailLabel.
This works fine in most cases but when my UIControl is arranged in a UIStackView it is refusing to size the table/cell's height any greater that 44.0.
I am using the CellStyle SubTitle and setting the Labels to be Multilines. They do wrap but appear outside of the Cell which appears fixed to 44.0.
I have set EstimatedHeight on Table and AutomaticDimension
Can anyone offer any suggestions as to why this might be.
Sent from my iPhone

Accessibility not working properly on UICollectionView inside UITableViewCell

in my app i have a UICollectionView and UIPageControl inside UITableViewCell. UICollectionView has three different kind of cells and each cell covers the full width of iPhone. With accessibility on we are facing a problem when the focus is on UIPageControl and we try to adjust its value by swiping up and down and then traverse back to the cell it loses its focus and takes us to some different cell instead of taking control to the cell which we have changed using UIPageControl.
We are changing the cell on value change event of UIPageControl.

CollectionViewCell keeps properties of old cell when reused

I have a UICollectionView with several cells. At time properties of views inside the UICollectionViewCell change. I noticed that when one of the cells is reused the "new" cell "inherits" these changed properties from the old cell – even though they are set to their initial state in the initializer of the cell.
This is happening with AutoLayout Constraints posed on Views inside the Cell and the alpha property of views (things like the text of a UILabel and the image of a UIImageView are changing exactly like they should).
Is this common behavior or is there something wrong with my code? Is there anything I can do about it?

Artifact on UITableView

I've created a UITableView and am using a custom UITableViewCell for the first row of this table. The only issue is there is some sort of artifact in the top left hand corner. Clicking in the area where this box is causes it to temporarily disappear and then reappear again. The box is always there. The UITableViewCell consists of the following:
UITextView (Description)
UIImageView (Image on far right)
UILabel (Character count)
I've tried removing all of these subviews and the box still appears.
If the box still appears even if you remove all the subviews of your custom cell, then it must be coming from another cell which has a frame outside its bounds. For example, a header view. One way to test this is to make sure you enable subview clipping for all your views.

UILabel in UITableViewCell Getting Drawn Over Accidentally

I'm using a prototype cell inside a grouped UITableView to create custom cells with two UILabels inside. Each UILabel is populated with text. The first UILabel, alligned on the left of the cell, behaves appropriately.
However, the second UILabel, which is toward the middle of the cell, is somehow being drawn behind the cell's background! I can't explain why, but if I set the background color of the cell to be clearColor instead of the default, the 2nd Label can be seen and works just fine. It also shows up if I highlight the cell, but disappears again when unhighlighted. I am sure that the label isn't just "blending in" with the background; the background is white and the label is black.
Any ideas? I'm a bit stumped. Is there some sort of issue with prototype cells and having more than one label?
Edit: Answered my own question, see below.
Okay, this has been resolved!
So like I said, I was setting up prototype cells in interface builder with two UILabels. To access these UILabels in my cellForRowAtIndexPath delegate method for my UITableView, I was using the Label's Tags. The first label I had tagged as "1", and the second label tagged as "3" (don't ask why it is 3 and not 2). Anyway though, it turns out that UITableViewCells already have a label with special properties setup with tag 1. Besides the label with tag 1 hiding my 2nd label, it was also remaining centered in the cell when I was changing cell size dynamically (when I wanted it to stay at the top).
Long story short: UITableViewCells have a "special" label already built in with tag of 1, so I changed my first label's tag to 10 and everything went back to behaving as I would expect.

Resources