How To Stop keyBoard Appearence at click event on UITextview? - ios

In my IPad Application i am using TextView only for Text Displaying.As i need to display a Larger Text Thats Why i am using UITextview due to its Scrolling Property instead of using UILabel.
In my application i do not need to edit Text in UITextview ,but problem for me is that when i click on Textview for scrolling the keyboard appear its hide my textview so i want that my keyboard is never appear on click event.i make a search but not find any Suitable solution.Any help will be appriated.Thanx

NEW ANSWER (previous one was not working properly)
OK so since that is not working because it disables scrolling also, you should try to:
Implement UITextFieldDelegate protocol
In your view controller add the text
#interface YourViewController () <UITextViewDelegate>
In viewDidLoad set yourself as a delegate:
yourUITextView.delegate = self;
Implement the delegate method below:
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView
{
return NO;
}
When the textview is about to edit the text, this method will be called automatically. It returns no, so the editing won't start.
It is very important that you undo the changes from the previous answers: Do not set the editable field to NO
I tried it and it's working. Hope it helps!
OLD ANSWER
when you declare the variable, or in your viewdidload method, set the editable property to NO:
yourUITextView.editable = NO;
or
[yourUITextView setEditable:NO]
That should prevent the keyboard from appearing.

Go to .XIB file and you can uncheck behavior editable or programmatically
textView.editable = NO;

Related

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.

UITableViewController scroll default behaviour

I'm using a UITableviewController with textField and text view in cells. By default when i click on a textfield the tableviewcontroller scroll the content up for let me se the content of the field. This default behaviour is very useful, but i've implemented a toolbar with a done button (inputAccessoryView) when i edit the textView. This is a problem when I switch from editing the textField to editing the textView, because the toolbar of the keyboard is just above the textView.
I've tryed a lot of solutions but nothing work for me. I've tryed something like this: https://developer.apple.com/library/ios/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/KeyboardManagement/KeyboardManagement.html
but doesn't work for me because i suppose this behaviour is already implemented in UITableViewController.
PS: the UITableViewController was created with Interface Builder. I don't know if this information is useful.
If you set up your UITableViewController to implement the UITextViewDelegate protocol, then you can know when you begin editing the textView by implementing this method:
- (void)textViewDidBeginEditing:(UITextView *)textView
{
//then you can scroll the tableview up so you can see the textView
[self.tableView setContentOffset:CGPointMake(0, /*height of your toolbar*/) animated:YES];
}

UITextview doesn't enter editing on touch

I'm having trouble getting my UITextView to become editable when it is touched.
I've included the following code per the Apple documentation.
-(BOOL)textViewShouldBeginEditing:(UITextView *)textView{
NSLog(#"begin editing");
return YES;
}
-(BOOL)textViewShouldEndEditing:(UITextView *)textView{
NSLog(#"end editing");
return NO;
}
I"ve also read through the apple documentation and have made the textview the delegate, but it still doesn't seem to be working. I'm pretty much trying to go with the notepad affect where once you are finished editing, numbers and such are hyperlinked.
In order to have that notepad effect, where numbers and links are hyperlinked, you would need to replace your UITextView with a special CoreTextView. I'd modify something like this to your needs: https://github.com/jasarien/CoreTextHyperlinkView. So in textViewShouldEndEditing: you would populate your CoreTextHyperlinkView text with textView.text, hide the textView and show your CoreTextView. And vice versa in textViewShouldBeginEditing:.
Also, make sure you reference the <UITextViewDelegate> protocol in your header.
Remember to set your textView's delegate, otherwise those methods won't get called
self.textView.delegate = self; // assuming self is the view controller with your textView
And remember <UITextViewDelegate>

picker wheel that only appears when selected

I have a view controller that displays various UITextfields to edit information. For one UITextfield I need a picker wheel to select predefined statuses.
Problem is I don't have enough space to integrate a picker wheel, is there a possibility to make it appear only when the text box is selected?
You could set the UIPickerView as the UITextField's inputView.
This will ensure that the picker is shown automatically when the text field gets focus, and hides it when lost.
E.g.
myTextField.inputView = self.myPickerView;
See the documentation on this property.
Assuming your "picker wheel" is a UIView, just hook up your controller as the UITextField's delegate and implement the following:
- (void)textFieldDidBeginEditing:(UITextField *)textField {
self.pickerWheel.hidden = NO;
}
You need to call your UIPicker in (BOOL)textFieldShouldBeginEditing:
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
if (textField==self.yourtextfield) {
//call your wheel in here
}
}
Look at
How to Show UIPickerView when selecting UITextField

How to prevent the keyboard from showing (not dismissing) on a TextView?

I would like to know how to DISABLE (not how to dismiss) the iOS keyboard in a TextView. I don`t even want the keyboard to show up when the user touches the TextView.
All of the examples I found were to make the keyboard disappear AFTER it appears.
The closest thing I got was to set textView.userInteractionEnabled = NO; but that gets rid of the scrolling as well (I want to keep the scrolling).
Thank you in advance!!
Try to implement the following method in text view's delegate:
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView{
return NO;
}

Resources