How do I clear the 3 textField values on button "Save" click - swift4

The screenshot is shown here:
I entered the values in these 3 textField ,
Now on button "Save" click, I want to clear the text in those 3 textfield at a time.

Set empty text on save button click action.
nameField.text = ""
ageField.text = ""
salaryField.text = ""

Related

Localize button Swift

For example I've got an app which has a textLabel and a button which are firstly set as:
mainLabel.attributedText = "labelNewText".uppercased()
mainButton.titleLabel?.attributedText = "buttonNewText".uppercased()
Then I've created a Localization file, where I set a some values for a German language:
"labelNewText" = "Etikette";
"buttonNewText" = "Taste";
And rewrote set ups for label and button like:
mainLabel.attributedText = "\(NSLocalizedString("labelNewText", comment: ""))".uppercased()
mainButton.titleLabel?.attributedText = "\(NSLocalizedString("buttonNewText", comment: ""))".uppercased()
Though, right after after I change my phone language setting to German, the translation only works for a Label but is not working for button. What am I doing wrong and how to localise button titleLabel?
You have to use UIButton's setAttributedTitle:forState: instead of trying to manipulate the text label itself. So for example:
mainButton.setAttributedTitle(myAttributeString, forState: .normal)

ion-searchbar to have cancel icon instead of cancel text ionic 3

I need to have cancel icon next to ion-searchbar. Now I have text as Cancel next to ion-searchbar. The text if provided by me and now I want to replace the text with image.
<ion-searchbar name="doSearch" (search)="doSearch($event)" [(ngModel)]="searchFilter" [showCancelButton]="true" cancelButtonText="Cancel" placeholder="Search" (ionCancel)="searchCancel($event)" (ionInput)="onInput($event)" (ionBlur)="onInputBlur()" (ionFocus)="onInputFocus()" (ionClear)="onInputClear($event)" >
I tried to remove the cancel button and also tried getting the element and inserted the class name.
var element = document.getElementById(".searchbar-ios .searchbar-ios-cancel .button-inner");
element.classList.add("fa fa-angle-down fa-2x down-arrow");
It throws an error stating TypeError: null is not an object (evaluating 'element.classList')
Can you let me know to to get Cancel icon instead of cancel text in ion-searchbar.
Remove [showCancelButton]="true" cancelButtonText="Cancel" from ion-searchbar. You will get remove icon button by default.

Swift UITest - No match found for textField with accessibility identifier

Trying to create a UITest for entering an email address/password into text fields and then hitting a login button. Using Xcode.
I watch the UITest navigate to the proper page, but it does not detect the text fields. I made sure that both text fields have the "Accessibility" box checked, and I've given them identifiers.
I'm getting this error:
UI Testing Failure - No matches found for text field
func testExample() {
let app = XCUIApplication()
//Test login page
app.buttons["loginButton"].tap()
//Here it navigates to the desired page
let emailField = app.textFields["email"]
emailField.tap()
emailField.typeText("xxx.xx.edu")
let passwordField = app.textFields["password"]
passwordField.tap()
passwordField.typeText("xxx")
app.buttons["loginButton"].tap()
// let loginAlert = app.alerts["alertVC"]
// XCTAssertEqual(loginAlert.title, "Error")
}
The accessibility indicators are "email" and "password" respectively. Logging in works fine when I run the simulator myself.
EDIT: Apparently there are no text fields at all (count = 0) even though I see them and use them on the page...
Image of storyboard with text fields:
If UITextFiled set SecureTextEntry true, you should use:
let passwordField = app.secureTextFields["password"]
I was having the same problem and I solved by unchecking the "accessibility enabled" box for the "views" of ViewControllers

Hide placeholder Programatically using swift 3x

How to hide the placeholder of TextField programmatically using Swift 3x ?
You can not hide the placeholder of UITextField, but you can set it to empty String.
self.textField.placeholder = ""
Now textField doesn't show any placeholder later on if you want to show the placeholder simply set it with String that you want.
self.textField.placeholder = "Enter name"

Xamarin. listview click on button inside list item

I am creating a listview which has many elements and one element is expand button. When I click on expand button i want to show some more button which are hidden with each list item. ( i.e each list item has separate buttons)
I know how to add click event with button inside listview item
in my custom adapter ..
getView(){
var expandBtn = findViewById(_)..
expandBtn.click += (sender,e)=>{
// this block should do show hide of my other buttons.
// how to get them here.
};
}