-
Notifications
You must be signed in to change notification settings - Fork 418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tapping a button in the StatusBar does not work on iOS device (iPhone Xr) #3589
Comments
I played around with this a little bit and found that iOS does not seem to deliver events to the app at all when the status bar is clicked. One workaround might be to hide the status bar. Right now this isn't possible because the prefersStatusBarHidden setting is hard-coded in the CodenameOne_GLViewController... it is toggled on and off when the keyboard is shown/hidden. I did test with this set to YES, and confirmed that it will deliver the taps in @ThomasH99's test case. See [2] below also for some hacks to be notified of taps on the status bar. None of this looks like something I would want to put into our general tap handling flow. Perhaps we could add a build hint to hide the status bar, but I'm not sure that this is quite what you're looking for. To solve the problem at hand, it might take a native interface to do one of the hacks suggested in [2] below. Ref:
|
Thanks a million @shannah for looking at this, with holidays I completely missed your feedback. Since iOS apps almost all scroll to the top of the screen when the status bar is tapped, I guess the event is delivered in some other way to the app. Would it be possible to map that call to a method on the main app class (similar to what is done for However, I guess this means you cannot add additional functionality to react on statusbar longpress and double-tap like I've done :-( Otherwise, hiding the statusbar could always be useful for some apps, but I had the impression this was already possible in CN1 (can't remember how right now). |
@shannah Sorry to be a bother, but following up on this again and hoping some solution exists :-). I've tried to find work-arounds at the app-level. But nothing really works well and feedback is that missing the tap-statusbar-to-scroll-to-top is quite annoying (just about every single iOS app implements this, so no good way to justify that a CN1 app doesn't). Just to summarize, I would prefer to have access to the individual pointer events from the statusbar to enhance the functionality (like I already did and which works in the Simulator), but I can understand if this is a rare case, so simply being able to react to a tap on the statusbar would be better than nothing. |
This approach looks like the easiest to adapt. https://stackoverflow.com/a/39585227/2935174 override func viewDidLoad() {
let scrollView = UIScrollView()
scrollView.bounds = view.bounds
scrollView.contentOffset.y = 1
scrollView.contentSize.height = view.bounds.height + 1
scrollView.delegate = self
view.addSubview(scrollView)
}
func scrollViewShouldScrollToTop(_ scrollView: UIScrollView) -> Bool {
debugPrint("status bar tapped")
return false
} The general idea would be:
Reference cn1-native-controls for examples of native component wrappers: https://github.com/shannah/cn1-native-controls If you don't want to have to write Objective-C directly, you could use the Cn1ObjC library to write it all in Java. |
Thanks again @shannah ! I'm afraid this kind of development is out of my reach (or would require too much time to build the competences). I guess I'm hoping that @shai-almog will take pity and find a way to make this work, it definitely seems worth having this in CN1 to enable this common gesture in CN1 apps. And it seems to still an 'official feature' since https://www.codenameone.com/developer-guide.html says "statusBarScrollsUpBool: Indicates that a tap on the status bar should scroll up the UI, only relevant in OS’s where paintsTitleBarBool is true" - although it is unfortunately probably one of the bugs where it is easier to change the documentation than the code ;-) I found the Apple link and add it for reference: https://developer.apple.com/documentation/uikit/uiscrollview/1619421-scrollstotop |
Any chance? |
Bumping it up again :-) For me personally, I'd prefer simply to be able to place an (invisible) button over the status bar and then use it to do whatever I want, but intercepting the standard iOS scrollToTop would be better than nothing. Reading the Apple doc (https://developer.apple.com/documentation/uikit/uiscrollview/1619421-scrollstotop?language=objc), I wondered if another solution could be to place an invisible / zero-height native "scroll view" near the top and use that to intercept the call? I’ve tried to google (in case different search words could dig something useful up ;-)) and found these https://stackoverflow.com/questions/59639974/how-to-detect-touch-on-status-bar-ios-13 Says to add this code: override func touchesBegan(_ touches: Set, with event: UIEvent?) {
} https://stackoverflow.com/questions/30443177/touchesbegan-not-called-in-uiview-subclass |
What we currently have is a touch area at the top. In the simulator this works perfectly as you can tell. The problem is the iOS simulator/device. Unfortunately, we don't use iOSs scrolling mechanism so this won't work for us. |
Describe the bug
From Reddit post with same title.
I am working on implementing the standard iOS feature tap-to-scroll-to-top in my app. My approach is to replace the standard StatusBar (an empty container) with a button which I size to the same size as the StatusBar container (defined by the default CN1 theme).
However, it seems that the default height (defined by the "StatusBar" uiid in the default CN1 iOS theme) is too small and on the device (iPhone Xr), tapping the button doesn't work (although it works fine in the Simulator).
I'm guessing that either the default height of the StatusBar is too small (so maybe not reaching down into the 'tappable' area of the screen) or that some other issue prevents tapping the top of the screen (like the safeArea?).
I can post a test example code if the above description is not sufficient.
Shai feedback:
We already have that code: https://github.com/codenameone/CodenameOne/blob/master/CodenameOne/src/com/codename1/ui/Form.java#L598-L624
I'm guessing that the pull down in iOS native is grabbing the tap but I never got around to investigate this in xcode.
To Reproduce
Code I used to test on device (you can play around with the size of the statusbar and check whether the touch registers or not):
Expected behavior
Taps on the device statusbar should be sent to the underlying components. This is happens correctly on the Simulator.
Smartphone (please complete the following information):
The text was updated successfully, but these errors were encountered: