I am implementing the split screen feature for the iPad Air 2 and iPad Mini 4. I'm trying to detect when the size of the split screen changes. When running as the primary app, either the viewWillTransitionToSize
or willTransitionToTraitCollection
will be executed. If my app is running as the secondary app, the viewWillTransitionToSize
function is called when opening the secondary app or while in landscape mode, changing from 1/4 to 1/2 of the screen. When I change the secondary app from using 1/2 to 1/4 of the screen, no functions are called to help indicate that change. Is there supposed to be a function called?
Swift viewWillTransitionToSize Not Called With Split Screen
1.5k views Asked by Mike Walker At
1
UPDATE
If you're using UICollectionView you need to draw attention to UICollectionViewLayout method which is called
shouldInvalidateLayoutForBoundsChange:
Basically this method is called every-time bounds (not size) of your collection view is changed and if you answer YES your collection view relayouts.To experiment you may (e.g. by subclassing UICollectionViewFlowLayout) override this method like this:
If it works for you may try some more efficient way to return YES only when actual size is changed. Something like this
that would be more natural than using
viewWillTransitionToSize