Post

Replies

Boosts

Views

Activity

SwiftUI TabView with PageTabViewStyle calls onAppear of children multiple times on iOS 14.2
On iOS 14.2, when using the TabView in SwiftUI in combination with a PageTabViewStyle, the onAppear function of its children will be called excessively. When running the app on iOS 14, onAppear is called exactly once for each child when it appears. Steps to reproduce: Add the following code to a view: TabView { 		Text("First text") 				.onAppear { 						print("First text appeared") 				} 		 		Text("Second text") 				.onAppear { 						print("Second text appeared") 				} 		 		Text("Third text") 				.onAppear { 						print("Third text appeared") 				} 		 		Text("Fourth text") 				.onAppear { 						print("Fourth text appeared") 				} }.tabViewStyle(PageTabViewStyle(indexDisplayMode: .never)) run the app in a simulator or on a device swipe through the tabs Expected behavior: The message is printed once when swiping between tabs. Actual behavior: (iOS 14.2) The message is printed multiple times when swiping between tabs. (iOS 14) The message is printed once when swiping between tabs. Radar: FB8907671
2
0
4.3k
Nov ’20