Follow

Something that tripped me up recently was not understanding how .onAppear { } behaves on iPad.

It gets called multiple times, even though the view is not visible.

Why? Logging reveals the size class is also changing, so presumably iOS is taking snapshots for the app switcher.

If like me you rely onAppear to denote a user has seen something (say, Mark as Read), you'll need to check the scenePhase first.

Here's a gist: gist.github.com/phillipcaudell

@phill I’ve seen this, but never thought to check the scenePhase - you’re saying onAppear is called, but the scenePhase is .inactive?

@matt1corey the scenePhase reports .background, but yes! A little confusing at first, but I suppose it makes some sense.

Sign in to participate in the conversation
The Not So Big Company

The home of The Not So Big Company on Mastodon.