Cannot add a textview to a toolbar? - ios

This has been bothering me for few weeks.
Here's a screenshot:
I copied this view Controller from a sample project.
Now I need to replace the Textfield with a UITextView instead.
The problem is I can't seem to be able to drag and drop it to a Bar Button Item.
I literally removed the textField then tried to drag and drop the textview, the Bar Button Item just wont highlight.
What am I missing?
PS: it works with UITextfield only.. why ?? o.O'

I think you are referring to the inputAccessoryView, it's a UIView which gets displayed when the textview becomes first responder. hence when the keyboard shows.
You can customize the UIView to hold all controls you want: textview, buttons, etc. More details here.
Basically, you implement your custom keyboard tool bar which is a UIView subclass (I assume you want something like the messages app), then you set the custom UIView to the inputAccessoryView property of the UITextView. here is a relevant link to get you started: http://gabriel-tips.blogspot.com/2011/05/input-accessory-view-how-to-add-extra.html

Related

Add Cancel Button to UIKeyboard

I want to add a cancel button to hide the keyboard if the user wants to. I cant find any solution for swift 3.
Take a look at the documentation of a UITextField's inputAccessoryView: https://developer.apple.com/reference/uikit/uitextfield/1619627-inputaccessoryview
Assigning a view to this property causes that view to be displayed above the standard system keyboard (or above the custom input view if one is provided) when the text field becomes the first responder. For example, you could use this property to attach a custom toolbar to the keyboard.
I recommend to assign a UIToolbar that contains your cancel button to the inputAccessoryView of the UITextField that needs the cancel button. Then hook up an action to the button that resigns the first responder from the UITextField.

What is the correct approach for dismissing the keyboard when using a UITextView?

I am wondering what the best approach for dismissing a keyboard is when using a UITextView. At the minute for UITextFields I dismiss the keyboard when the return button is pressed. However for the TextView I want to have the return button actually add new lines so there is no additional buttons remaining to close.
What if any is the current "standard" approach for dealing with this issue? For example is it to add an additional button on the screen or is there another approach?
Thanks
On the iPad there is a "dismiss" button on the keyboard. For iPhones, add an inputAccessoryView to the UITextView. Put a "dismiss" button there.
If you have several fields (text fields, text views, etc.) in some sort of form, you could have a standard inputAccessoryView for all of them. Include a "Next" button (to go to the next field) and a "Done" button (to dismiss the keyboard).

ios7: UIButton on UINavigationBar is not selectable

I have a pretty unique problem. I have a custom nav controller (https://github.com/cwRichardKim/RKSwipeBetweenViewControllers) and I'm trying to customize it even further. The effect I'm trying to get is this:
What I have is this (ignore the search bar):
The problem that I have is that when you click on any of the tabs in my nav bar ("public" for example), the click doesn't register, and it clicks whatever is underneath instead. For example, if I click "Munchies", it will click the search bar underneath the tab. Also, even if there is nothing clickable underneath it (I've tried this with a blank UIViewController), the tabs (eg: "Munchies") are still not clickable.
I have a theory for why this is. If I raise the tabs by a few pixels, the tops of the tabs become clickable. So, I think the navigationBar has a frame within which you can interact with its objects, but if you interact with anything outside of that frame, it interacts with lower layers. I've tried expanding the nav bar height and it doesn't work (I've looked it up and it's against the rules).
Any thoughts?
Thanks!
I read your code here that is shown here:
https://github.com/cwRichardKim/RKSwipeBetweenViewControllers/blob/master/RKSwipeBetweenViewControllers.m
I'm not exactly sure whether this will work out. But this issue has occured to me in table cell as well. Perhaps you can try typing this in.
[navigationView setUserInteractionEnabled:NO];
I'm pretty sure that your approach is on the right track because as I read Apple documentations it says:
Custom views can contain buttons. Use the buttonWithType: method in UIButton
class to add buttons to your custom view in the style of the navigation bar.
Custom title views are centered on the navigation bar and may be resized
to fit.

iOS UIKeyboard with NO Done button [duplicate]

I need to show UIKeyboard with done button on top right corner ..please look into attached image..any help would be appreciated.
This might help you. please check it out BSKeyboardControls
Create a UIToolbar keep two bar buttons in that. Initially Hide that toolbar.
Show the toolbar on the textfield didBeginEditing delegate of textfield
and hide the toolbar in didEndEditing delegate of textfield
EDIT: As prashant said BSKeyboard offers what i said. See the look and feel of it here http://www.cocoacontrols.com/platforms/ios/controls/bskeyboardcontrols
You should set inputAccessoryView propery of UITextField or UITextView to your custom view with all required buttons
#property(readwrite, retain) UIView *inputAccessoryView
Description
The custom accessory view to display when the text field becomes the
first responder The default value of this property is nil. Assigning a
view to this property causes that view to be displayed above the
standard system keyboard (or above the custom input view if one is
provided) when the text field becomes the first responder. For
example, you could use this property to attach a custom toolbar to the
keyboard.

2nd uitextfield in modal view not taking keyboard input

I am presenting my modal view using UIModalPresentationFormSheet and I am aware some have had issues resigning first responder and dimissing the keyboard in the past, but my issue is that the second textfield I pick I can't input text. This is hapenning in iPad simulator 4.3.
This happens if I select the second uitextfield while the keyboard of the first textfield is still visible. The cursor will move to the second textfield, but I am unable to edit it. Most of the time I am unable to click the bottom right button which would dismiss the keyboard in iPad, but if it works, I can then select the second textfield and be able to edit it.
Has anyone encountered these issues before?
I am also implementing
-(BOOL)disablesAutomaticKeyboardDismissal { return NO }
Even though this is not a solution it is a workaround. Basically you use a pagesheet instead of form, and resize it.
UIModalPresentationFormSheet resizing view
Even though this is not a solution it is a workaround. Basically you use a pagesheet instead of form, and resize it.
UIModalPresentationFormSheet resizing view

Resources