Hello,
I have a tableView Cell that's setup to display a graph. This is done by having a 1:1 UIImageView displaying a UIImage of a graph I created.
I've got code that calculates where to create a second UIImageView to show the data plot on the graph, using the imageView bounds to determine the position.
The problem I'm having is that there appears to be an issue with the constraints. And I can't figure out how to fix.
I've tried multiple different ways to set this up. Currently I have UIView (subView) inside of the container view. the subView is pinned to 40 from the super view on all sides, had a 1:1 aspect ratio, and is centered X and Y on the containerView.
Then inside of this subView, there is a UIImage of the graph pinned 0 on all sides.
The image loads correctly. However, I plotted UIImages in each corner to see where the bounds / frame are, and these appear to be loading incorrectly. - Which is causing the point to plot wrong initially on load. But then does correct itself once it's reloaded. Either by calling the cell to reload directly, by when its dequeued and reloaded.
I'm not sure how to load photos here, but I had a thread on StackOverflow as well that has pictures of the issue here:
https://stackoverflow.com/questions/62925314/tableview-cells-resizing-auto-layout-issue-on-load-but-fixes-after-second-rel?noredirect=1#comment111330305_62925314
Any help on fixing these constraint issues would be greatly appreciated!
Thank you!
I have a tableView Cell that's setup to display a graph. This is done by having a 1:1 UIImageView displaying a UIImage of a graph I created.
I've got code that calculates where to create a second UIImageView to show the data plot on the graph, using the imageView bounds to determine the position.
The problem I'm having is that there appears to be an issue with the constraints. And I can't figure out how to fix.
I've tried multiple different ways to set this up. Currently I have UIView (subView) inside of the container view. the subView is pinned to 40 from the super view on all sides, had a 1:1 aspect ratio, and is centered X and Y on the containerView.
Then inside of this subView, there is a UIImage of the graph pinned 0 on all sides.
The image loads correctly. However, I plotted UIImages in each corner to see where the bounds / frame are, and these appear to be loading incorrectly. - Which is causing the point to plot wrong initially on load. But then does correct itself once it's reloaded. Either by calling the cell to reload directly, by when its dequeued and reloaded.
I'm not sure how to load photos here, but I had a thread on StackOverflow as well that has pictures of the issue here:
https://stackoverflow.com/questions/62925314/tableview-cells-resizing-auto-layout-issue-on-load-but-fixes-after-second-rel?noredirect=1#comment111330305_62925314
Any help on fixing these constraint issues would be greatly appreciated!
Thank you!
I figure it out.
The view was having issues laying out because it was square, and dependent on the size of the device. The image was being layout before the cell finished setting up.
Fixed it by using:
The view was having issues laying out because it was square, and dependent on the size of the device. The image was being layout before the cell finished setting up.
Fixed it by using:
Code Block override func layoutSubviews() { super.layoutSubviews() print("layoutSubviews()") plotGraph() }