Constraining UITableViewCell to change when editing - swift

I have a UITableViewCell that has a UIImageView 20 pts in from the left. When I tap "Edit" to edit the contents of my UITableView and the red edit circle comes in from the left, how do I properly set up my constraints so the left of my UIImageView is constrained to the right of that red edit circle view?
Note: I'm doing layout in code, not using Storyboards or xibs

This would be handled automatically if you make sure that your views are subviews of the contentView in the UITableViewCell and your constraints are applied to the contentView.

Related

How to scroll a UIView to a certain height and after reaching that point scrolling inside the UIView?

Hey guys I'm new to swift programming. I've been stuck with this problem for a long time. So I have a UIView that starts in the middle of the ViewController, inside the UIView (green) is another UIView (yellow) with dynamic labels in it, so the height can change. You should be able to scroll the UIView(green) up until the NavigationBar and then you can scroll "in" the green UIView to see the rest of the content in the yellow UIView.
How can I achieve that you can scroll to a certain height and then change to scrolling inside the green UIView? Rough Construction of the UIViewController
I have a scrollView for the green UIView, and I set it under the NavigationBar, but it doesn't stop there, you can pull it over that point. Then I tried to set another UIScrollView inside the green UIView to scroll through the yellow content but I don't know how to constrain it because it's dynamic.
I'm thankful for every tip you guys have.

tvOS UIImageView Focus Shadow Clipped

I have a UICollectionViewCell in a UICollectionView containing two components
1 x UIImageView
1 x UIView
The UIView would ideally contain a couple of labels, and has the following properties set as default:
backgroundColor = .clear
isHidden = true
The UICollectionView has clipsToBounds set to false.
In the delegate of the UICollectionView, I am using the didUpdateFocusIn function to determine which cell will receive focus next, and un-hide the UIView.
As the UIImageView has the adjustsImageWhenAncestorFocused set to true, there is a drop-shadow drawn by tvOS when it automatically applies the zoom + parallex effect.
As can be see in the two pictures below (the second picture has the UIView's backgroundColor set to .black for clarity), the shadow is clipped by the empty space belonging to the UIView in the cell beside it, even though the UIView is already hidden.
Is there some way that I can resolve this?
Edit: Have added a third image which shows the shadow behaving perfectly when the UIView is totally removed from the .xib.
Well, it turns out that I'm a bumbling fool.
I forgot that I had set the bottom constraint of the UIImageView to be anchored to the top of the UIView that was below it.
The net result of hiding the UIView caused the UIImageView to seek out the bottom of the UICollectionViewCell, and that caused the clipping issues.
I have now constrained the UIImageView to a fixed height, and the problem has been resolved!
Since tvOS 11, there is no need to bind your view constraints to the UIImageView constraints to get that effect.
You can get that effect making use of the new property overlayContentView of UIImageView.
Link to the documentation:
https://developer.apple.com/documentation/uikit/uiimageview/2882128-overlaycontentview
A more elaborated explanation can be found from the minute 15:00 of the following WWDC video:
https://developer.apple.com/videos/play/wwdc2017/209/
If the method offered by Apple to get this effect, is not enough for your specific case, I also recommend this great third party library which basically allows getting a Parallax effect in any UIView.
https://github.com/PGSSoft/ParallaxView

UITableViewCell Background Color?

I have done a fair bit of googling on this and I can't find the right solution. I have a UITableView of which I want to change the colour of the background of the cells. I have found solutions to doing this but it only deals with cells which have content or data as it were.
I need to colour the background of those unused cells as well.
Try setting the background colour of the tableView itself. Those "empty cells" at the bottom aren't really cells at all - they're just separator lines drawn over the background.
Even though UITableViewCell inherits from UIView, changing the backgroundColor property of the cell itself won't do anything. You need to change the background color of the cell's contentView, such as
cell.contentView.backgroundColor = [UIColor greenColor];
This is because the subviews of a UITableViewCell are actually subviews of the cell's contentView, because the contentView knows how to resize its subviews if a cell is put into editing mode; the cell itself doesn't know how to do that.
I'm not sure what you mean by unused cells. If you tell your tableView there are 10 cells and you only provide content for 8 of them, you'll still have 10 green cells, if that's what you mean by "unused".

iPhone - UITableviewcell label movement when press Editing

In the normal behavior when Edit is pressed, the red delete circles appear from the left. This shifts the entire cell to the left.
When this happens, custom labels on the far right of the cell overlap the cell movement touch area.
The solution is to move custom UILabels to the left when edit is pressed.
How is this done?
Assuming your UILabel is being added to the contentView of your cell, just make sure your subviews (whether a UILabel or other UIView-derived object) have their autoresizingMask set up to allow flexible width (UIViewAutoresizingFlexibleWidth). Also, your left subviews need UIViewAutoresizingFlexibleRightMargin, while your right subviews should have UIViewAutoresizingFlexibleLeftMargin.

Accessing grouped UITableView section view?

Basically I want to "cut the corners" of the first cell imageview and the last cell imageview to match the curved corners on the grouped tableview section.
I was given the advice to do this by setting the view's masksToBounds property to true?
Anyone know how to access this view? Doing cell.superview doesn't work. cell.contentView.superview doesn't work and cell.backgroundView.superview doesn't work.
Anyone have any ideas?
There is no section view. A cell's superview is the UITableView itself.
The rounded corner drawing is done by UITableViewCell's backgroundView, and backgroundView isn't in imageView's view hierarchy (contentView and backgroundView are siblings—their superview is the Cell itself), so unfortunately masksToBounds won't work.