I have a SwiftUI Form with a Section that contains a DatePicker. The DatePicker is set to have a datePickerStyle of CompactDatePickerStyle(), by default, since it's in a Form.
When tapping on the DatePicker, the overlay is presented:
The DatePicker's time is able to be modified by using a gesture, as seen in the following video:
In the following video, tapping on the overlaid DatePicker's time to modify it via the keyboard causes the overlay to be dismissed:
I have also tried adding the following to the DatePicker in order to allow for inline date manipulation, hoping for keyboard avoidance:
.datePickerStyle(GraphicalDatePickerStyle())
.ignoresSafeArea(.keyboard, edges: .bottom)
However, the above results in the following:
What do I need to change to allow the DatePicker to be manipulated via gestures and keyboard input within the form?
You need to raise the datepicker so the keyboard wouldn't show over the datepicker, already reported this bug in October 2020 and the ticket is still open. These datepicker don't have keyboard avoidance. Also found an issue with GraphicalDatePickerStyle that can crash the app, ticket still open too.
Did you try to use .ignoresSafeArea(.keyboard) on the entire Form? I had the same issue and this fixed it for me.
Related
I am looking at this SwiftUI tutorial and it suggests I can see extra actions upon Command-Clicking the SwiftUI elements in code. In my Xcode, this jumps me to the class definition.
I see there's an option in XCode 11.0 t change the Option key to show SwiftUI inspector, however, this still does not let me modify SwiftUI code elements using actions like "Embed in VStack"
How can I get both inspector and extra SwiftUI actions when interacting with SwiftUI Code (not the preview)?
Extra SwiftUI actions show when Canvas is opened (shortcut: Option-Command-Enter or ⌥+⌘+↵):
canvas is closed
canvas is opened
The accepted answer doesn't work for me on macOS 10.15.5 and Xcode 11.4.1.
The Good news is that you can get it via a shortcut of [Command][Shift][Left Click] on a SwiftUI element or by clicking Show Code Actions on the right click menu.
Instead of using the mouse, I recommend using the Xcode hotkey for bringing up code actions. Navigate to Preferences -> Key Bindings and search for Show Code Actions. You'll see the preset hotkey which you can then customize. My default key binding was Shift+Command+A. Just make sure you cursor is over the intended element when you press the hotkey.
You can change the command click behavior where you were looking under Xcode -> Preferences, Navigate tab.
Rather unintuitively, if you pick "Selects Code Structure", then command+click will bring up the SwiftUI menu options you're looking for (granted the canvas is open).
If you do this, you can still jump to definition via control+command+click
Conversely, if you'd prefer to continue to use command+click to jump to definition, you can instead use control+command+click to bring up the SwiftUI menu options.
Command clicking on a view will not work in Xcode 12.2 and 12.3 (under MacOS 10.15.5) if you have your preferences different than Xcode expects.
You have to change your Navigation preferences for Command-click on Code: to Selects Code Structure before the proper menu will appear when you command click on a View.
To change this. press command , to open your preferences and select the Navigation button. The option you need to change is in the first popup menu.
Using SwiftUI and running into an issue with the keyboard. I want to use the .deicmalPad but I can't dismiss it since it has no "return" button.
Found a workaround: use UIApplication.shared.windows[0].endEditing(true) on a button. (Tried using it on the viewController for the app but it broke NavigationLinks)
Now I want to add the "Next", "Previous" and "Submit" strip above the keyboard, like in this picture: http://brainwashinc.com/wp-content/uploads/2017/07/Simulator-Screen-Shot-Jul-28-2017-9.07.42-AM.png
can't find SwiftUI documentation for this feature, only finding incompatable UIKit solutions involving inputAccessoryView and it's items.
Ultimatly want to use the "Submit" button's event to use UIApplication.shared.windows[0].endEditing(true) and finally get the keyboard to go away.
Thanks in advance
I built an Angular Reactive Form using Ionic 2.
When I was touching an input at the bottom of the page the page would scroll so the input get above the keyboard. Expected behavior, so ok. But the header was push too and that was wrong.
So I looked on the internet and find a workaround which was to write the following in the import statement of app.module.ts
// app.module
IonicModule.forRoot(MyApp, {
scrollAssist: true,
autoFocusAssist: true
})
That indeed works well as the page still scrolls and the header is not push away.
But I still have one problème. When I touch an input which doesn't need the keyboard to be shown (eg. datepicker) the page scroll on the first touch and I have to touch again so the datepicker opens...
Any idea on how I could may be prevent the page to auto-scroll when touching an input that doesn't need the keyboard?
This could be possibly achieved by using two properties of input component. Firstly you can set the readonly property to true and then add the click Eventlistner to open the DatePicker and then use the placeholder property of input to show the value of DatePicker.
I hope this would help you find the solution. Let me know if this works.
Good Luck & Cheers
Ashish Sebastian
I made my own keyboard by buttons and I want to never show the Apple keyboard even by touching the text field? How is that done?
Set your custom keyboard view as the inputView of the textfield.
textField.inputView = customView
Then the keyboard will show with your custom view. And you get all the animations and stuff for free.
If you don't want your custom view in the iOS keyboard you might need to check out something like what this guy explains in this SO answer
We have a rendering listing the selected items in a TreeSelect in the current item. In our case we call them "Tags" (1)
We have added a Field Editor Button to the component to let the editor change selected items. (2) (As described on for example Adding a custom component)
When an editor clicks (2) the editor window (3) it is opened in a dialog. The editor may select different items(called tags in our case) using the TreeSelect.
When the editor presses the ok-button (4) the values are set.
Now to the problem:
The values are actually set as they get stored when the editor presses the Save button but we want our list on the page (1) to immediately reflect the set items when the editor presses the ok-button (4), i.e. before having to actually save the whole item.
How do we achieve that?
(I am in contacts with Sitecore support but so far I have not gotten any answers...)
Update
After a lot of conversation with the support we still have no useful solution.
We tried turning it into a field renderer displaying the links.
What worked was:
The field do get updated when you have edited it in the popup field editor. (but...)
It looks good the first time when page is loaded.
You can make a WebEdit button with commands to edit the field and add it as Custom button to the field (register <command name="webedit:fieldeditor" type="Sitecore.Shell.Applications.WebEdit.Commands.FieldEditor, Sitecore.Client"/> and set Click on the button to webedit:fieldeditor(command={3473DDA1-2983-493C-AF7A-054C75AA7AD3},fields=NameOfField where the guid points to itelf and an "Icon" is set on it.)
What didn't work was:
The field get updated by the raw value, not what I want to display. Server code is involved, but not in the rendering of html-code.
When I want to edit the value in the field editor, the value sent to the field editor is not the raw value but what actually is displayed on the page. (I guess this can be solved somehow)
The issue to the support turned into a feature request to let the server be involved in rendering the field, not just sending a new value to the JavaScript updating it. The server does the first rendering so when it already is involved in updating, it should be allowed to do the rendering the following times too.
We have decided to not spend more time on this right now (we have other things to do too.) and have a bad editor experience as the field not get updated until the editor actually saves the item.
Still we have no suitable solution for this issue. If you want to keep working on it and want a reference to my issue it is 439059.
This may not be useful here. I've done this in normal sites, but not in Sitecore. But, here's one possibility....
This is a situation where you would pass a callback function to the child popup window. This callback will cause the caller / parent window to re-read/re-load the information that was just updated by the child.
Example:
User presses (2) to open Editor Window(3) (Editor window is opened and the Callback function is passed as a parameter)
User presses "OK" button (4). The "OK" button event handler updates the changes, then calls the Callback function which re-loads the now updated information, and closes the popup window.
Once the popup closes, the parent window now displays the information that the popup/editor just updated.
This takes some client side javascript (jquery) development but it is quite do-able normally.