This question came up, a customer wants to add payment, with gesture, to their app. This gesture is a swipe, from bottom to top (like when minimizing applications). The question immediately arose, will the application pass the review with such UI/UX ? Will there be any problems ? I'm not talking about problems when the user can minimize the application when paying, or pay (accidentally) when minimizing. I want to know if there will be any problems from Apple's rules when releasing the app ? I haven't found the exact information yet
Post
Replies
Boosts
Views
Activity
I've caught a very strange problem (THAT ONLY OCCURS ON REAL DEVICES) that has to do with using @NameSpace and MatchedGeometryEffect using NavigationStack. The problem is that if I go from the first screen to the second screen (on the second screen I have a View with MatchedGeometryEffect) , I get a strange bug where the MatchedGeometryEffect animation starts to work very badly (ONLY ON REAL DEVICE), it feels like the animation frame count drops to a minimum, but on simulator or preview everything works fine as it should.
However, if I use the screen without NavigationStack, there is no such animation problem. What can this be related to ? And how can this be fixed ?
It only takes a couple of lines of code to catch the animation problem, but it took all day to figure out what the problem is.
FirstView
struct NameSpaceTest2Navigation: View {
@State private var nameSpaceTest2Path: [String] = []
var body: some View {
NavigationStack {
Button(action: {
nameSpaceTest2Path.append("nameSpaceTest2")
}, label: {
Text("Button")
})
.navigationDestination(for: String.self) { path in
NameSpaceTest2()
}
}
}
}
Second View
struct NameSpaceTest2: View {
@State private var selection: Int = 0
var body: some View {
VStack {
TabView(selection: $selection) {
ForEach(0..<5, id: \.self) { _ in
Color.white
}
}
.tabViewStyle(.page(indexDisplayMode: .never))
}
.overlay(alignment: .top) {
NameSpaceTest2Header(selection: $selection)
}
}
}
Third View
struct NameSpaceTest2Header: View {
@Binding var selection: Int
@Namespace var sectionUnderline
var body: some View {
ScrollViewReader { scrollReader in //START: ScrollViewReader
ScrollView(.horizontal, showsIndicators: false) { //START: ScrollView
HStack(spacing: 0) { //START: HStack
ForEach(0..<5, id: \.self) { index in
VStack { //START: VStack
Text("Name: \(index)")
.foregroundStyle(Color.green)
.padding(.horizontal, 24)
.padding(.vertical, 15)
.overlay(alignment: .bottom) {
if selection == index {
Rectangle()
.fill(Color.red)
.frame(height: 5)
.matchedGeometryEffect(id: "sectionUnderline", in: sectionUnderline, properties: .frame)
.transition(.scale(scale: 1))
}
}
.animation(.smooth, value: selection)
} //END: VStack
.onTapGesture {
withAnimation(.smooth) {
scrollReader.scrollTo(index)
selection = index
}
}
.tag(index)
}
} //END: HStack
} //END: ScrollView
.onChange(of: selection, perform: { value in
withAnimation(.smooth) {
scrollReader.scrollTo(value, anchor: .center)
}
})
} //END: ScrollViewReader
}
}
Try to repeat this code and run it on a real device with NavigationStack and you will get a bug with the animation, it will twitch like it has 5-10 frames per second.
Then try to run Second View without Navigation Stack and you will get smooth animation, which is what it should be.
What could be the problem ? How to get the smooth animation back ?
Once again, you should only test on a real device.
The following type of problem has appeared. I need to flip through the video. Imagine you have, say, 3 videos, and you can scroll through them and choose which video you want to watch.
For this, I decided to use a TabView with the .page style. But it turned out that it didn't work. And I found myself in a stupor.
The TabView itself starts to lag, the scrolling starts to lag, the videos do not start the first time, and sometimes the control panel does not even appear on some videos, which is why it is impossible to expand the video to full screen.
The code will be below, maybe someone has encountered this problem, how did he solve it, maybe there are some other options to make a similar logic?
let videos: [String] = ["burpee", "squat", "step-up", "sun-salute"]
var body: some View {
TabView {
ForEach(videos, id: \.self) { videoName in
VideoPlayerView(videoName: videoName)
.clipShape(RoundedRectangle(cornerRadius: 25))
}
}
.frame(width: 375, height: 230)
}
struct VideoPlayerView: View {
let videoName: String
var body: some View {
if let videoURL = Bundle.main.url(forResource: videoName, withExtension: "mp4") {
VideoPlayerWrapper(player: AVPlayer(url: videoURL))
} else {
Text("No Video \(videoName)")
}
}
}
#Preview {
VideoPlayerView(videoName: "squat")
}
struct VideoPlayerWrapper: UIViewControllerRepresentable {
let player: AVPlayer
func makeUIViewController(context: Context) -> AVPlayerViewController {
let controller = AVPlayerViewController()
controller.player = player
controller.showsPlaybackControls = true
return controller
}
func updateUIViewController(_ uiViewController: AVPlayerViewController, context: Context) {}
}
After I upgraded to Xcode version 14.0 an error appeared. When starting the simulator.
objc[8958]: Class SBFCARendererImageRepresentation is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/SpringBoardFoundation.framework/SpringBoardFoundation (0x1382b95a0) and /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/PaperBoardUI.framework/PaperBoardUI (0x1385b5930). One of the two will be used. Which one is undefined.
I did not attach much importance to this, I thought that it would not be in the next update, but now I have upgraded to Xcode version 14.0.1 and the error has not disappeared, I do not quite understand what is required of me to fix it.
Good afternoon, perhaps after the update someone had a problem with the consumption of RAM. Regardless of whether Swift or SwiftUI simulator consumes at least 8-10 gigabytes of RAM.
The usual empty project in which it says "Hello World". If I run two simulators already, then the RAM consumption goes for 20+ gigabytes.
There was no such thing before the latest updates. Previously, one simulator consumed 1.5-2 gigabytes, but not 10. How to deal with it ? Derived Data was cleaned. Xcode itself was completely removed and reinstalled, currently version 14.0.1. Who has encountered this, please tell me how to solve this problem? Or is this a problem with the 14th version of Xcode itself ?