Post

Replies

Boosts

Views

Activity

List bug with contextMenu and scaleEffect
Thanks for taking your time to help others :) And for instance, I already checked all the solutions of this post, but none worked for us. Posted also at StackOverflow, I publish here also hoping for better luck. Thanks! Bug description: As we are building a chat, we need messages to display in the reverse order of a List/ ScrollView has. That's why we are putting everything upsideDown. On iOS 15 and iOS 16 (not in 14), there is an strange behaviour (seems a bug) when showing contextMenu on a reversed List/ScrollView. Depending on the method you use, it will even disappear. Let's dive in. Code simple demo to show what happens. import SwiftUI struct ContentView: View { var body: some View { ScrollView { // It also happens using List (instead ScrollView + LazyVStack) LazyVStack { ForEach(1..<101, id: \.self) { msg in messageView(msg) .upsideDown() // Upside down each element, you can try .upsideDownBis() } } } .upsideDown() // Upside down entire ScrollView, you can try .upsideDownBis() } private func messageView(_ msg: Int) -> some View { Text("Msg no. \(msg)") .padding() .background(Color.red.cornerRadius(8)) .contextMenu { Button(action: { print("A") }) { Text("Button A") } Button(action: { print("B") }) { Text("Button B") } } } } // Just for setting upside down list/ ScrollView extension View { func upsideDown() -> some View { self .rotationEffect(Angle(radians: .pi)) .scaleEffect(x: -1, y: 1, anchor: .center) } // This one just rotates, does not disappear. func upsideDownBis() -> some View { self .rotationEffect(Angle(radians: .pi)) } } GIF resources of this behaviour on iOS 15 and 16: iOS 15/16 when applying upsideDown() modifier -> Bug: iOS 15/16 when applying upsideDownBis() modifier -> Undesired animation: What we have checked? As mentioned before, every solution posted at this post and some others. The ideas apart from those have been: As scaleEffect is really causing the worst part of the bug, I did try to set x: -1 to x: 1, when performing a contextMenu gesture... But seems faster than longPressGesture "recogniser". Similar to 1. but on upsideDownBis() trying to avoid the animation, setting it to nil, nor making the modifier not to apply in that case... So, as things stand, I can't recognize a longPressGesture before contextMenu does appear. Questions Is there any work around for this? To not have that animation with upsideDownBis() ? Is there any work around for this? To not have that bug with upsideDown() ?
0
1
845
Jan ’23
Status bar color in iOS 16
Hello! Thanks for taking your time to help others. Problem description: Our SwiftUI app min deployment is iOS 14. We've been struggling with status bar* color just in iOS 16. We can't change its color/appearance from light to dark. (*) For instance, this picture refers to what I think is status bar (may be obvious, yes). Previous valid solution (iOS 13 to iOS 15) Since now we used to manage the appearance with ... Call in specific view, when a condition is given, like no dark mode supported, or side menu have been open UIApplication.setStatusBarStyle(.darkContent) The extension to support this on any SwiftUI View import UIKit extension UIApplication { class func setStatusBarStyle(_ style: UIStatusBarStyle) { if let controller = UIApplication.getKeyWindow()?.rootViewController as? ContentHostingController { controller.changeStatusBarStyle(style) } } } Actually, the controller class import SwiftUI import UIKit class ContentHostingController: UIHostingController<AnyView> { private var currentStatusBarStyle: UIStatusBarStyle = .default override var preferredStatusBarStyle: UIStatusBarStyle { currentStatusBarStyle } func changeStatusBarStyle(_ style: UIStatusBarStyle) { self.currentStatusBarStyle = style self.setNeedsStatusBarAppearanceUpdate() } } But, as I said, this stopped working with iOS 16. What we have checked? As we googled it... Using .preferredColorScheme modifier, changes the app appearance, and we want to keep, for example, the dark theme along light status bar. So it's not an option. Applying .toolbarColorScheme (iOS 16), does nothing. Manage Info.plist without success. Light content by default, could be changed (with the method described above) Questions Why is this not working in iOS 16? Are we doing something wrong? (worked like a charm for 13 to 15). Is there any generic (iOS 13 to 16) way that you actually use and work? (If not) Do you know any workaround to apply on 16 only?
2
1
5.4k
Dec ’22
Remove native gesture UIKit
Hello! I need due to a buggy behaviour on my app to remove a tap gesture from QLPreviewController. I must say I didn’t add one for my own so I assume is the native one. QLPreviewController allow me to pinch, tap double tap… and obviously preview any kind of document. BUT as I said, tap gesture makes code bug, keyboard in particular. So I need to get rid of that gesture. Any idea? Thanks in advance
1
0
400
Jun ’22
Backwards navigation when app goes background
Hello! thanks for taking your time to help others. Problem description: While developing a SwiftUI app, for iOS 14 or later I found a bug. You are located at one view. From this view, you can only navigate backwards, with: @SwiftUI.Environment(\.presentationMode) private var presentationMode (defined on view properties) And self.presentationMode.wrappedValue.dismiss() at back button action. If you send the App to background, and open it again... it results that app has navigated backwards, without any action from the user. What I have checked? Breakpoints at button action: It just don't reach that point, as expected (we are not pressing the button). Checked for similar behaviour on other views, to check if it also navigates backwards while on background: Negative, just happens there As long as I know, nothing has been developed to control app workflow when App comes to background Error message [_Snapshotting] Snapshotting a view (0x11b00aa00, UIKeyboardImpl) that has not been rendered at least once requires afterScreenUpdates:YES._ Which I think has nothing to do. I don't know what else I can try. Any suggestions?
0
0
379
Mar ’22