I am using the Eureka forms library in Swift but don't appears add or delete icons
This is the code:
+++
MultivaluedSection(multivaluedOptions: [.Reorder, .Insert, .Delete],
header: "Directions",
footer: "") {
$0.addButtonProvider = { section in
return ButtonRow(){
$0.title = "Add New item"
}
}
$0.multivaluedRowToInsertAt = { index in
return TextRow { row in
row.placeholder = "step"
}
}
$0 <<< TextRow { row in
row.placeholder = "step"
}
}
somebody knows if i am omitted a step or what do i need to do?
Thanks
I just add
tableView.isEditing = true
in viewDidLoad()
Related
I am trying to solve the following problem. I created a "List looking like " List with ForEach Loops. Which works just fine just not for one problem. In the last ForEach loop I would like to give a result in text if there is no result in the database "values". So if the ForEach loop does not go thru because there is no database set then I would like to give a Text result saying "0€".
Do you have any ideas?
Here the code:
ForEach(categories.filter({ (categories) -> Bool in
categories.inOrOutCategory_ID == 1 }), id: \.category_ID) { categoryIndex in
Section(header: Text("\(categoryIndex.category)")) {
ForEach(subCategories.filter({ (subCategories) -> Bool in
subCategories.category_ID == categoryIndex.category_ID }), id: \.subCategory_ID) {
subCategoryIndex in
HStack {
Text("\(subCategoryIndex.subCategory)").padding(.leading)
Spacer()
ForEach(values.filter({ (values) -> Bool in
values.subCategory_ID == subCategoryIndex.subCategory_ID && (values.month_ID == self.month && (values.year == self.year)) }), id: \.value_ID) { valueIndex in
Text("\(String(format: "%.2f", valueIndex.value))€").padding(.trailing)
}
}
}
}
}.padding(.leading)
Thank you very much
I had the same problem today, the solution would be to create a method which would be true or false which checks the conditions of the filters manually then it will be necessary to create the view in swiftUI which is displayed if the method returns false (no result ) for example and in your view you display a text or whatever you want with no results
example :
func searchResult() -> Bool {
if searchText == "" {
return true // ne s'affiche pas
}
for u in subscribers{
if u.firstname.contains(searchText){
return true
}
if u.lastname.contains(searchText){
return true
}
}
return false // s'affiche
}
in you view :
if !searchResult() {
Text("test")
}
I'm trying to write text to a textfield, clear the text and the write a new text. I can't get rid of the old text. The new is written on the old so I see them both. I'm using choosefile and trying to show the selected file in a textfield so I can confirm the selection.
class TestView : View("My View") {
var tf: TextField by singleAssign()
override val root = BorderPane()
init {
with(root) {
center = form {
fieldset("Main") {
field("File") {
vbox {
tf = textfield()
tf.text("678")
tf.clear()
tf.text("999")
}
}
}
}
}
}
}
I expected to to see '999' in the textfield but I see both 678 and 999 at the same place.
You are actually calling the text() builder on the textfield, so you're basically creating two text elements inside the text field. I think you should take a step back and read the guide before you go further :) Here is a cleaned up version of your code:
class TestView : View("My View") {
val filename = SimpleStringProperty()
override val root = borderpane {
center {
form {
fieldset("Main") {
field("File") {
textfield(filename)
button("Browse...").action {
val filters = arrayOf(FileChooser.ExtensionFilter("All Files", "*.*"))
chooseFile("Choose file...", filters).firstOrNull()?.let {
filename.value = it.path
}
}
}
}
}
}
}
}
I have a Search Bar with a UITableView and if I search something in the searchBar it will print the result in the table view.
If I search a name like "Name 01" and I click on this name to get information and later I re-open the Search Bar and I try to search other name like "Name 02" I will see the "Name 01" result in the Table View and I don't know how to clear it.
I have tried to refresh Table View too but without success.
Video of the problem: https://streamable.com/98j0w
The code is this
extension LocationSearchTable : UISearchResultsUpdating {
func updateSearchResults(for searchController: UISearchController) {
//print("updateSearchResults")
if searchController.searchBar.text == nil {
seenNames.removeAll()
matchingItems.removeAll()
self.tableView.reloadData()
}
guard let mapView = mapView,
let searchBarText = searchController.searchBar.text else { return }
let request = MKLocalSearchRequest()
request.naturalLanguageQuery = searchBarText
request.region = mapView.region
let search = MKLocalSearch(request: request)
search.start { response, _ in
guard let response = response else {
return
}
for (index , name) in response.mapItems.enumerated() {
let item = response.mapItems[index]
if(checkIfItemExistInDatabase(key: String(item.name!)) != nil && !seenNames.contains(name.name!)){
matchingItems.append(item)
seenNames.insert(name.name!)
self.tableView.reloadData()
}
}
}
}
}
I want that If I do a research the tableview result with searchbar text is cleaned and doesn’t show the previously result
Instead of:
if searchController.searchBar.text == nil {
...
...
Try with
let searchText = searchController.searchBar.text
if searchText == nil || searchText.isEmpty {
...
...
And another thing, just before
search.start { response, _ in
add
matchingItems.removeAll()
tableView.reloadData()
I have gone through the doc but no luck. Where as there is autocomplete in the github repo. Please provide a working example of tornadofx auto complete combobox?
In it's simplest form, you just call makeAutocompletable() on a ComboBox. Here is a complete view with a Form.
class MyView : View() {
val selectedFruit = SimpleStringProperty()
val fruits = listOf("Apple", "Banana", "Pear")
override val root = form {
fieldset {
field("Fruit") {
combobox(selectedFruit, fruits) {
makeAutocompletable()
}
}
}
}
}
I've got a simple IBAction that performs a method (let's just say shows subview). When I press this button again I want to perform another method (hides subview).
I have done the coding for the show/hide. I have tried using a Boolean but am unsure of the syntax. I also tried using an if/else statement like this:
var doubleTap = false
if (doubleTap) {
//hide view
} else {
//show view
}
If someone could shed some light on this that'd be great!
change to code like below in the Button Press Method:
var doubleTap : Bool! = false
if (doubleTap) {
//Second Tap
doubleTap = false
} else {
//First Tap
doubleTap = true
}
A function which is doing this in one line:
var toggled = true
func toggle() {
toggled == true ? (toggled = false) : (toggled = true)
}
If you wanna let a button appear and disappear again this can be an approach:
import UIKit
class MyViewControllerClass : UIViewController {
var buttonActive : Bool = true {
didSet {
self.mySubView.hidden = !self.mySubView.hidden
}
}
func toggle() {
buttonActive == true ? (buttonActive = false) : (buttonActive = true)
}
}
Take a Global variable and intialize it to 1 and when it First time pressed intialize it to 1 in the function perform the task you want to do. Then if you presses it second time intialize it to 0 and then perform the other task