how to disable uikeyboard of textview ,if the editing mode enabled - ios

How to hide/disable keyboard ,if the textview editing is enabled.
I only want to that user can only be able to select the text and can't be allowed for entering text.
Because selected text will be converted in to image for move animation.
User will not be allowed for entering any text in textview so that's why keyboard should be hidden or disable ,he will be allowed only for text selection.

uitextview.editable = NO; or set checkmark in IB. It will allow to select text with options - Copy and Select All without keyboard appearing. Tap on the word and hold to select text.

ok just uncheck the behavior of you UItextview in .xib file.

Something to try it the 'editable' setting doesn't work out is to create a UIView that's hidden and out of the way somewhere and assign it as the inputView for the text view. If that property is non-nil, the view it contains will be shown instead of the keyboard.
Such as:
self.textView.inputView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 1, 1)] autorelease];

try this
yourtextview.UserinterationEnable=No;

This will make the keyboard disappear:
[[[UIApplication sharedApplication] keyWindow] endEditing:YES];
This what you want to do?

Related

UITextField inputView displays undo, redo, paste buttons

I have created a custom inputView for my UITextField. The view itself looks and functions great, but on the iPad I'm getting undo, redo, and paste buttons above my custom inputView. How do I remove those buttons? They don't have any functionality, but they should be removed.
With Swift 3 and XCode 8 I was able to remove the bar by removing the two button groups on the text field input:
self.textField.inputAssistantItem.leadingBarButtonGroups.removeAll()
self.textField.inputAssistantItem.trailingBarButtonGroups.removeAll()
// hide undo, redo, paste button bar for textfield input view
UITextInputAssistantItem* item = [your_textfield inputAssistantItem];
item.leadingBarButtonGroups = #[];
item.trailingBarButtonGroups = #[];
will hide the top bar for input view.
Reference:How to hide the shortcut bar in iOS9
Try removing the inputAccessoryView:
self.textField.inputAccessoryView = nil;

Not properly add inputAccessoryView for UITextField

There is a requirement of inputAccessoryView is for the chat application.
When I add inputAccessoryView to UITextField on tap event of UIButton. That view is set as inputAccessoryView completely but text field is not becoming first responder.
(Note: Super view of textfield is viewText.)
- (IBAction)btnOpenTextField:(id)sender
{
UIView *accessoryView=[[UIView alloc]init];
accessoryView.frame=CGRectMake(0,0, _viewText.frame.size.width, _viewText.frame.size.height);
[accessoryView addSubview:_viewText];
_txtMessage.inputAccessoryView = accessoryView;
[_txtMessage becomeFirstResponder];
}
Thanks in Advance.
You can call [_textMessage reloadInputViews], replacing [_text becomeFirstResponder].
What you want to achieve is quite not possible, this will cause recursion, alternatively what you can do is put a textfield on bottom of the screen and when the textfield is selected you can animate it up with the flow of the keyboard. i think this is an appropriate solution if i got your question correctly.

How to keep cursor of a UITextField in focus after dismissing keyboard?

I am trying to dismiss the OS keyboard and keeping the cursor of the UITextField still in focus, I am trying to do this because I am building a custom stickers keyboard..
So the problem is that after I call the resignFirstResponder, the keyboard gets dismissed, witch is a wanted behaviour, but also the cursor gets dismissed, witch I want to keep in focus.
You should have to display a temporary view as the keyboard, and everything else works the way it should.
UIView *tempView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
textField.inputView = tempView; // Hide keyboard, but show blinking cursor
It works for UITextField and UITextView and they need to be set to editable.
There is no way to do that. However, in simulator you may press Cmd+K and that will dismiss keyboard but leave focus there (this is a simulation of hardware keyboard). But in general, UITextField cannot have a cursor while not being a first responder. If you wish, you can write your custom one

UITextField frozen with no keyboard

Can anyone think of a reason that a UITextField would resignFirstResponder, and then no longer respond to touches to becomeFirstResponder? I have a situation where I have a view controller that appears, but the keyboard disappears immediately, and the text field still has the cursor, but it's not blinking. Tapping on the text field will cause the "paste" menu option to appear and I can paste text into the field, but I cannot make it become first responder.
Any thoughts would be greatly appreciated...
I've had to deliberately create this scenario before for a previous app and the way i did it was to set the input view for the textfield to a tiny dummy view.
UIView* view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1, 1)];
myTextField.inputView = view;
Although I believe this still showed the blinking cursor.
To get the blinking cursor to stop as well I had to return NO in the shouldBeginEditing method.
-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
return NO;
}
So if you are doing either of these things you would get the behaviour that you're currently experiencing where the textfield is actually responding but it is isn't showing a keyboard or a blinking cursor.

How to disable keyboard when clicking a UITextField in iOS?

I am currently developing a prototype that I want to do user testing on desktop first before loading to iPad.
I am looking for solutions to disable the keyboard after clicking a textfield. That means after clicking a textfield, user is able to enter information from the macbook keyboard directly, and the virtual keyboard that automatically shows up in the simulator will not appear. I have been through a lot of tutorials but they are all dismissing the keyboard after user entry; that is not what I am looking for. How should I hide the keyboard?
Thanks so much!
Use this:
UIView *dummyView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
myTextField.inputView = dummyView; // Hide keyboard, but show blinking cursor
It works for UITextField and UITextView and they need to be set to editable.
What you did Here:
You created a dummy view of width=hight=0, & assigned it as the inputView of your textField.
How It works:
Instead of showing default, keyboard, now, the viewController is showing DummyView as inputView for your UITextField. As DummyView has Width=height=0, You will not see anything on the screen :)
Here is another answer which I found the same hack but with little additional supportive code snippet to hide the blinking cursor too.
-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
return NO; // Hides both keyboard and blinking cursor.
}
I needed this to be done for a Quantity text field where I increase/decrease the quantity using a UIStepper view. So I needed the keyboard to be hidden always.
This will set the inputView of your textField to, basically, an empty UIView with no frame.
self.theTextField.inputView = [[UIView alloc] initWithFrame:CGRectZero];

Resources