I have a detailed view controller. It is made up of dynamic, model based, text label subviews that are placed by code on the view within a scrollview with set spacing. I have anchored the last text label (lastLabel) to the scrollview bottom anchor with the following:
The above line was added on the suggestion from a DTS ticket, and it solved some other label subview and scroll view issues.
However, the problem I'm having, on all device sizes by the way, is that if I start in portrait orientation, my lastLabel is displayed as expected with correct spacing to the previous (above) text label, but then when I rotate to landscape orientation, then rotate back to portrait orientation, the lastLabel is shifted down and spacing to the previous (above) label is increased.
If I navigate back to the parent view, then return again to the detail view in portrait orientation, the lastLabel is correctly positioned again relative to the previous (above) label.
I don't seem to be able to figure out how to fix this bug so that the lastLabel on the view always retains the proper spacing to the previous (above) label, even after transitioning from landscape to portrait orientation.
I do not see this problem when transitioning from portrait to landscape. The landscape orientation always displays the lastLabel in the correct relative position to the previous (above) label.
Code Block scrollView.bottomAnchor.constraint(equalTo: lastLabel.bottomAnchor, constant: 0).isActive = true
The above line was added on the suggestion from a DTS ticket, and it solved some other label subview and scroll view issues.
However, the problem I'm having, on all device sizes by the way, is that if I start in portrait orientation, my lastLabel is displayed as expected with correct spacing to the previous (above) text label, but then when I rotate to landscape orientation, then rotate back to portrait orientation, the lastLabel is shifted down and spacing to the previous (above) label is increased.
If I navigate back to the parent view, then return again to the detail view in portrait orientation, the lastLabel is correctly positioned again relative to the previous (above) label.
I don't seem to be able to figure out how to fix this bug so that the lastLabel on the view always retains the proper spacing to the previous (above) label, even after transitioning from landscape to portrait orientation.
I do not see this problem when transitioning from portrait to landscape. The landscape orientation always displays the lastLabel in the correct relative position to the previous (above) label.
Had a good 1-on-1 lab session with DTS this morning. They gave me a couple of different options to fix this. It’s gonna take some work so I have to decide which approach to use. One of the approaches is to use some of the new Xcode 12 Beta APIs for iOS 14 to replace my current approach to my detail view controller and instead use an advanced collection view that might make things much simpler and let the collection view API handle all the spacing.