I have a TableView with some Cell's that contain a UITextField and some with a UITextView.
While presenting a UITableViewController i'm getting a strange behavior. The TextView has a property called "Selectable":
If I leave this checked, the last Cell that contains a TextView becomes automatically focused. And Of Course the keyboard will popup and hide content.
If I don't check it, it won't become focused when the view loads - that's what I want - but no touches in the Cell's TextView are not recognized.
So any idea why:
The Selectable property prevents any touches?
Whats the difference then between Selectable & Editable?
Any Solutions for my dilemma?
selectable means that data detectors (dates, addresses, etc., in accordance with the dataDetectorTypes property setting) act as links.
editable means that the user can type, select, copy, and paste the text itself.
Also, don't trust the Interface Builder (nib editor) interface on these properties. Set them in code.
Related
Bear with me as this is a difficult issue to describe. I have two UICollectionViews: MainCollectionView and NestedCollectionView. The MainCollectionViewCell holds a UILabel and the NestedCollectionView. In turn, the NestedCollectionViewCell holds either a UILabel or a UITextfield. Whether the UILabel or UITextfield is shown depends on the content for the NestedCollectionViewCell.
My issue is as follows: when the user selects the NestedCollectionViewCell and the content is set to show a UITextfield, then a keyboard for user input shows up. This is expected.
However, when the user inputs some text then scrolls to another cell in the MainCollectionView, the NestedCollectionView gets reset and the UITextfield.text is set to the default. In other words, the inputted text is not preserved.
Any advice how I can solve this?
Your inputted text in UITextField is lost, because whenever you scroll your UITableView it will automatically destroy cells which are no longer visible, and this also required for better memory management otherwise your app will consume more memory. So when you come back to your previous cell, you have newly generated UITalbeViewCell. So your data is lost, because you haven't persist it.
So as a solution whenever your textFieldDidEndEditing called or whenever you dismiss keyboard store your UITextField values into some object, and in your cellForRowAtIndexPath method check if object has value then fill it to your UITextField.
In this way you always have your previously entered value as it is.
I've got a bit of a weird situation. I need to have an element not be read out by VoiceOver when I use the 2 finger swipe method, but to be read when tapping on it still.
The object is part of a TableView cell, and I've given the TableView cell its own accessibilityLabel, because it contains two interactive elements, one of which doesn't actually need to be read when tapped on, so I've disabled its accessibility property.
However, my other one needs to be read still when tapped on. The issue is, it's already being read as part of the cell's accessibilityLabel, and then it is read again because it is still an accessible element. Is there any way to differentiate between why VoiceOver is reading an element? Or to dynamically change the accessibilityLabel?
You can dynamically change accessibilityLabel simply by assigning it or overriding the method on the accessible view. However, you shouldn't rely on VoiceOver respecting the change in real time.
Users can navigate via tap or swipe and expect elements to persist regardless of how they were reached. In general, I discourage clever solutions that assume how users interact with VoiceOver.
I'd encourage you to either override the cell summary to omit the label or disable accessibility on the label and leave the content in the cell summary.
Object C - iOS development. Hello all. I have a static table view with several text boxes to enter information. When I tap on a lower box, the keyboard hides the text box preventing entry of text. This app uses another static table view controller and when a lower text box is tapped, the view scrolls up allowing text to be entered, so it works fine. I must be missing a setting of some sort, but can't find it. Your help is greatly appreciated.
If you have a full screen table view controller by a subclass of UITableViewController then the keyboard interaction will be handled for you.
If you don't (you aren't using UITableViewController) then you need to do it yourself. Basically, you need to observe the keyboard notifications and use the keyboard frame they provide to you to change the table view frame so that it isn't below the keyboard.
See the docs for UIKeyboardDidShowNotification here. You might also like this project.
I want to use UITextFields for inputting relatively small amounts of text. The text can be longer than the size of the text field, and I want the user to be able to touch/scroll inside the text field in order to be able to read all of it.
This type of semi-scroll-like behavior is available in edit mode, but I don't want the user to be able to edit, just scroll. The keyboard shouldn't come up in other words. (I do allow the user to do editing, but that's in another section of the app.)
I'm suspecting that UITextField wasn't built to do what I'm trying to do and that I should go explore the capabilities of UITextView instead. Since I've already made a fair investment in providing the infrastructure to support UITextField editing (when it's needed, just not in the current circumstances), I'm a bit reluctant to abandon UITextFields altogether.
Does anyone see a way of doing what I want to be able to do?
Howard
y dont u use UITextView instead of textfield with small size
Use a scroll view with the UILabel as the subview of the scroll view?
Alternatively, use a UITextView and set its editable property to NO. If you are worried about the styling of the textview, use the plain style and customized with other UI elements.
I have UITableView where each cell consists of two UILabel, I want to show up keyboard when the cell is selected? Is it possible with UILabels?
If you just want to pop up a keyboard, you can add a tiny invisible (transparent 1x1 with transparent text) UITextField anywhere in any visible view and make this text field first responder to pop up a keyboard. Then you can redirect the input text to any of the two labels (or somewhere else) using the text field delegates to capture the input.
Yes, the label has to conform to the UIKeyInput protocol. Note that this is an either-or proposition. If the label conforms to UIKeyInput, then when it becomes first responder, the keyboard will be displayed, whether you want it or not.
I'm not sure how you mean this exactly since it is obviously not possible to edit two textfields for labels at the same time. Hence the following assumes you want to show the text in your cell using UILabel, but want to be able to edit the cell's text.
You can't directly use the keyboard to edit UILabels. The easiest solution is to directly use UITextFields instead of the UILabels.
An alternative is to have both a UITextField and UILabel in the cell. Then show the textfield (by settings itsß hidden property toYES`) when the cell is selected and hide the label. When editing is finished, do the reverse (i.e. showing labels, hiding textfields).
To show the keyboard directly after selecting the cell you can call [someTextField becomeFirstResponder];. To check if the user is done editing (and e.g. tapped the return key), you can set the delegate of the UITextField.