How to remove toolbar? - ios

I want to hide toolbar when a specific row is selected
This is the code if specific row in pickers is selected, show keyboard and input characters
if self.emailPickers[row] == "input by myself" {
email2Field.text = ""
email2Field.resignFirstResponder()
email2Field.inputView = nil
Please help me

You can use the same property for adding and removing the toolbar.
email2Field.inputAccessoryView = nil

Related

How to hide a label within uitableview custom cell

I have a custom UiTableView with a few cells.
Each cell contains a few UILabels.
somtimes I want to hide a specific label, while keeping its position empty, to avoid other fields repositioning.
in android, I used the following code:
holder.layoutTemperature.setVisibility(View.INVISIBLE); // hide, but keep its place.
if (myFlag) {
holder.layoutTemperature.setVisibility(View.VISIBLE);
}
How do I do it in swift?
You can any View's visibility like this:
myLabel.isHidden = true
You need this inside cellForRowAt
cell.lbl.isHidden = true/false
To hide the label but keep its position , you simply set its ".isHidden" to "true".
For example,
let label = UILabel()
label.isHidden = true

How to do Form Customization for Unhiding Fields

I am new to Ax,I am doing an customization on form.When I click on show more fields I want to show three more fields on form which are hiding(FieldC,FieldD,FieldF).Please tell me how to achieve this Functionality.
You can check an example in form VendTable > Design > MainTab > TabPageDetails > Tab > TabGeneral > HideShowGroup.
It contains two elements: a combobox (HideShowComboBox) and a button (HideShowButton).
By default, the button has following properties:
AutoDeclaration = Yes
Text = Show more fields
HelpText = Show/hide fields.
SaveRecord = No
Border = None
BackgroundColor = Dyn Background white
ImageLocation = EmbeddedResource
NormalImage = 7886
ButtonDisplay = Text & Image left
The button also has method clicked responsible for hiding/showing the fields that need to be hidden/displayed and for changing its own look (Text, HelpText, NormalImage = 7882, etc.)
Please note that this logic is managed in class DirPartyFormHandler - you can set breakpoints there and debug the process to understand this functionality better.

how to remove a button for a particular cell in tableview in swift 3

I am having a tableview in which radio button edit and delete buttons are placed in a particular table view in which the key value pair default_shipping is true then the delete button should be hided and edit button needs to move that place and here the user is able to change the default address by clicking edit button and can make another address to be default so that the selected address should have only edit button and the edit button should be placed in position of delete button can anyone help me how to implement this ?
Give Edit button's Trailing constraint to contentView instead of
delete button.
Take outlet of Edit button's Trailing constraint in UITableViewCell's class
Use below code in cellForRowAtIndexPath:
if indexPath.row == "your default_shipping cell's indexPath.row" {
editButtonTrailing.constant = 8
} else {
editButtonTrailing.constant = space between delete and edit button.
}

Change color of UILabel if UITextField (in corresponding UIView) is disabled? (Swift)

I have multiple inputs that are disabled/enabled based on certain conditions — is there a way to select the adjacent UILabel that is in the same view?
Here's a visual the UITextField/UILabel:
You can find any views in a view with a simple loop.
for view in view.subviews {
if let label = view as? UILabel {
// do something with your view
}
}
Use viewWithTag option ,give specific tag to textField and fetch them
if let theTextField = self.view.viewWithTag(1) as? UITextField {
print(theTextField.text)
}
I don't think there is a direct way of identifying the adjacent label for a field. You'd have to loop through the labels looking for one in the correct position.
Instead give your text fields tags 1-10, and give your labels corresponding tags 101-110.
Then use the tag number to find the label.

How to programmatically enter text in UITextView at the current cursor position

I would like to add (some predefined) text at the current cursor position in a UITextView using Swift. So if I have a UITextField named txtField that has some text in it already such as "this is a beautiful valley" and I tap in the area between "a" and "beautiful" so that the cursor is now in the space between "a" and "beautiful" and then click a Button on my user interface a string of text such as "very" will get typed at the cursor position, so that the text in the UITextView will now become "this is a very beautiful valley". At the end of this operation (after button click event) I would the cursor to be just after the word "very". Many thanks for your help. I can see some question on the forum with similar themes, but the answers are in Objective C. I suicidal like help using Swift.
Try this... Inside your button's IBAction use this (please do not use forced optional unwrapping) or else if the textView has no selection or cursor, the app might crash:
let txt = "whatever you want"
if let range = handleToYourTextView.selectedTextRange {
// From your question I assume that you do not want to replace a selection, only insert some text where the cursor is.
if range.start == range.end {
handleToYourTextView.replaceRange(range, withText: txt)
}
}
try this
textView.replaceRange(textView.selectedTextRange!, withText: "your text")
update:
Swift 5.2
let txt = "whatever you want"
if let range = myTextView.selectedTextRange {
if range.start == range.end {
myTextView.replace(range, withText: txt)
}

Resources