Ask Your Question
3

When presenting a BottomSheet in Two ViewController, why does the CALayer position have NaN?

asked 2021-10-31 11:00:00 +0000

david gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-06-26 19:00:00 +0000

ladyg gravatar image

There could be various reasons for this. However, one common reason is that the bottom sheet hasn't been fully initialized or laid out yet. When a view controller is presented on top of another view controller, it takes some time for the view hierarchy to settle and layout to occur. During this time, the frame and position of the bottom sheet layer may be undefined or NaN.

To resolve this issue, you can try delaying the initialization of the bottom sheet until the parent view controller's view layout is completed or override the viewWillLayoutSubviews method and manually update the bottom sheet's layer position once the parent layout is complete. Additionally, you can also check if the bottom sheet layer is nil before accessing its properties to avoid any crashes or undefined behavior.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-10-31 11:00:00 +0000

Seen: 12 times

Last updated: Jun 26 '21