I need to add two input AccessoryView into my UITextView.
First i need to add custom control from this link.
That custom control use
[KOKeyboardRow applyToTextView:self.txtView];
So when i add my custom accessoryView to my UITextView,only custom control is showing and mine are not displaying.
Here is code that my custom inputAccessoryView.
self.txtView.inputAccessoryView = self.keyboardAccessoryView;
So how can i add two inputAccessoryView into UITextView?
The inputAccessoryView is a single view. You need to create a single view (either a container or subclassing the 3rd party view) and add all of your content (buttons) to it.
Look at subclassing KOKeyboardRow just to expand the view that it uses as the inputAccessoryView and add your buttons to it. To do this cleanly you should change the public interface so that it takes a number of buttons (an NSArray property) as additional buttons that would be added below the standard buttons that it adds.
wrap the two views in one custom uiview
Related
What is the correct way to do view polymorphism in iOS? For example, I have custom table view cells that need to contain either a custom BarChartView or LineChartView. I decide at run time whether the table view cell will hold a line or bar chart. Ideally, I want to only create one xib file for the table view cell that layouts the bar/line chart view with other things (like labels for chart title, etc), and I can decide at run time whether the view that holds the chart is going to become a BarChartView or LineChartView. Is it possible to set the morphing view in the xib file in Interface Builder to be one of the superclasses, for example UIView, and then later programmatically decide which subclass it should become? If so, what's the best way to do that?
Step 1. Make two view in custom cell xib file for BarChartView or LineChartView.(Both in single xib only)
Step 2.Write conditions in cellFoRowAtIndexPath to get either BarChartView or LineChartView view to Show.
Note:- Now,there might be condition ,weather to show/hide tableview ,depends on you.
But once tableview need to be displayed, use Step 1 & 2 to dynamic view loading.
maybe have a custom view inside contentView of your cell and just add barChartView or lineChartView to that view. So, even If you need to support more Chart types that'll be doable
iOS Proficiency: Beginner
If I have a Xib with multiple fields that all need their own Picker View, what's an appropriate/canonical way to add multiple picker views on the page without getting the Design View all cluttered up?
1) Only add the PickerView programmatically and not via the XIB?
2) Use only 1 Picker object and populate it with different values based on the field
selection? (Possible memory benefits?)
3) Place the UIPickers on the View with a tiny height/width and then programmatically adjust height when necessary? Not even sure if the height is adjustable.
4)Combination of some of the above?
You can see in the image below, how cluttered it looks already even with just one picker view:
The view that you have with the text fields and picker views would lend itself to be part of a UITableView.
See the calendar app when you add an event.
You can set this up fairly easily by using a static UITableView.
I'm replying on my phone at the moment but will look for a tutorial if you would like.
If only one pickerView will be visible at once, then you should consider using only one pickerView and configure it's delegate/datasource so that you can give it a different datasource for each field.
Unless more than one is visible at once, there really isn't any reason to use more than one in your nib file. And even if you used more than one, you would still have to configure you delegate/datasource methods to handle each individual picker.
Hope that helps.
EDIT: It would be a little bit of work, but if you wanted the pickerView to animate in and out of the view whenever you need and if you wanted to clean your Xib up even more you could do the following:
Create a subview containing your pickerView
Set up a protocol on the subview to allow you to pass the selected value back to the view controller.
Set up your viewController to conform to the protocol on your picker subview.
Set the pickerView to be each textField's inputView.
Set the textField's delegate methods to configure the dataSource of your subview when editing begins.
By doing this, you have set your textField so that when it receives firstResponder that it will display the pickerView instead of a keyboard.
I'm building an interface in codes from scratch (there's nothing in XIB file). I'm adding a tableitem that consists of some cells and those cells contains one or more views (UIButton, UITextField, etc.)
The problem is none of the items are clickable/editable! When I click TextFields or Buttons, nothing happens! No highlighting, no cursor changing nothing at all...
What I'm missing here?
Also constructed the cells programmatically. I am adding controls directly to the UITableViewCell.
One possible issue: some of your views (may be ContentView or the UITableViewCell) hides the controls from manipulation. You should set that [UIView].userInteractionEnabled to false. You can also try to implement touch listeners to your views to recognize which one hides your controls.
How do I change UITableViewCellEditingStyleInsert default image to custom created?
Is there an easy way or I should create a custom UITableViewCell?
The standard API doesn't support any way to customize the green plus button used for UITableViewCellEditingStyleInsert.
Your only option would be use your own button added to a cell. You wouldn't be able to use the standard editing style features of UITableView. You would need to set the cell's editing style to None and use your own method when the custom button is tapped.
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.