iPhone UITextView scrollable but not editable - iphone

How can I get a textview to be able to scroll without the keyboard poping up for edit when clicked on? I am pretty new to iPhone programming and I've tried several different combinations in Interface Builder, but can't seem to get any to work. Also I am having trouble when I have two textviews on the screen where only one of them will scroll. Any help would be greatly appreciated.Thanks!

textView.editable=NO;
it is a property of UITextview, check the documentation
cheers

In IB, next to the "Text Color" box, untick the 'Editable' checkbox.

- (BOOL)textViewShouldBeginEditing:(UITextView *)textView{
return NO;
}
try to implement this UITextView's delegate method.

Related

UIMenuController not showing UIPasteBoard is cleared iPhone app?

Am working in message based iPhone application. In my application looking like iMessage native iOS app. I made Bubbles with used UIImageView and UILabel. I made UILabel as clickable and showing Copy option. It is working fine when the message input UITextView is not in active.
1. I can show the "Copy" option when we clicking UILabel and the UITextView is not becomeFirstResponder.
2. When the user clicking the MessageTextView (UITextView) from the bottom of the screen the UITextView becoming first responder and keyboard is showing now. In this scenario if the user clicking the messabe bubble (UILabel) the UIMenuItem showing "Paste" on the bubble instead of "Copy".
3. If i click "Paste" from the bubble UIMenuItem already copied text will be pasting in UITextView. So the control fully in UITextView UIMenuController not activated in UILabel. So i cleared the text from UIPateBoard when the user clicking the Bubble (UILabel).
4. Now the UIMenuController not showing up even [self becomeFirstResponder]; not becoming in UILabel class.
The reason is when the UITextView is in becomeFirstResponder the control fully in that. not coming to UILabel. Could you please help me on this.
How to show UIMenuItem "Copy" when the user clicking UILabel if the keyboard is in visible the control is in UITextView? Could you please help me on this. I spent two days in this issue. Thanks in advance.
May be I am wrong.CONSIDER THIS ANSWER AS A COMMENT.
I tried to achieve like what you are trying to do. Thats not working too. I figured out I cannot make access the two views at the same time. Especially when I have any view becomeFirstResponder and you cannot access menu items of other view.
But if you try like this,you may succeed in your code.
1) In the touchesBegan: method, find the user touching inside your UILabel.
2) If that happens, then show a custom view with buttons like copy,paste and select like that.

View come up on the keyboard window. How to solve it

I have list of the text filed in vertically. And all these are in one UIViewController and I am adding this UIViewController's View in my another class.
When I clicked on the text filed keyboard appears. And that scroll view comes on the keyboard window. How can i solve this. I am beginner and no idea about this problem.
Also when I open the UIPopover with date picker. And when I scroll the date picker for selecting the date the UIPopoverController also change in their layout.
Also I have attached the some screen shoot for better understanding of issue.
Got Answer
Thanks for your help. Solved my issue. In my demo code i have change some property of the UIView's Layer. For setting border, cornerRadius.
One More property i have set is "[self.view.layer setClipsToBounds:YES];". I don't know what is wrong in this but when i remove that line code just work fine.
But this property work fine with UIImageView.
Just comment below line from PaymentView.m file - (void)viewDidLoad method
[InnerView setClipsToBounds:YES];
Your question is not very clear with text,put some code.
However seeing the images in red block a suggestion could be reduce the y-axis of the y axis of your view which is coming over the keyboard.

how to check if a view is behind the keyboard on iphone

in my application i have a bunch of textlabels and textviews. Sometimes the textview is underneath the keyboard. My question is if there's a way to check if a textview is behind the keyboard to move it up. I already know how to move views up, and i know about the keyboardWillAppear notifications, but i don't know how to check if the view is behind the keyboard. The thing is that i don't want to move the textview if it's not underneath the kayboard. How can achieve that?
Thanks in advance.
I would do the check for first responder as shown above
[text isFirstResponder];
then I'd check to see if the bounds of the text field's bounds are less than 215 (because i think that's the max height of the keyboard) and accommodate from there. so all together it looks like:
if([text isFirstResponder]){
if(text.bounds.y > 215){
text.bounds.y = CGPointMake(text.bounds.y-(text.bounds.y-215));
}
}
I think the only way to see this is to verify each UITextField and UITextView if it returns YES for
[_text isFirstResponder];
If any UITextField or UITextView is First Responder, than it means that the keyboard is on the bottom of the screen.
You can see the keyboard will appear by listening to UITextFieldDelegate and UITextViewDelegate ShouldBeginEditing events:
for UITextField it is:
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField;// return NO to disallow editing.
and for UITextView it is:
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView;
Hope it helps.

UICatalog and Keyboard Events

The latest version of Apple's UICatalog example application includes zero code in the TextFieldController for handling keyboard show/hide events, and yet the table view still slides up and down beautifully with the keyboard.
Does anyone know what the new trick is? Are there settings in the XIB that allowed them to forgo registering for the notifications or using TextField delegate methods?
The TextViewController still uses keyboard notifications to deal with view sliding, so I'm really confused as to why this isn't included for TextFields anymore.
Thoughts?
You can close the keyboard, if it's open by calling:
[sender resignFirstResponder];
Not sure about opening the keyboard however.
The trick is hidden within calling becomeFirstResponder on a UITextField that is in a scrollable view. Apparently, whenever calling [textField becomeFirstResponder], iOS automatically scrolls the parent view until said textField is visible.
This behavior can actually be undesirable in some cases, as it will not usually scroll to the same location that the UIScrollView method scrollRectToVisible:animated: would if you were to try to do things that way.
Thanks for your thoughts everyone!

automatic scroll - a scroll view on Touch of textField - iPhone

I have many textfields in my Application which are in a scrollview.
What i need is when user touches on a textfield,
scrollview should scroll in such a way, so that that textfield should not be behind
the keyboard.
I've written a pretty straightforward tutorial on doing this, it mimics as much as possible the behavior of Apple own applications, if it can be of any help:
Adjust UITextField hidden behind Keyboard with UIScrollView
You can use the method - (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated in UIScrollView, this should scroll to the offset of the point you give it, you will need to figure out the offset through code
Maybe you could set the text fields' delegates to self, and then adopt the UITextFielDelegate protocol for the class, and then in this method:
- (void)textFieldDidBeginEditing:(UITextField *)textField
Make the scroll view scroll down enough so that you can see the text field.. I don't know how to make the scrollview scroll down though.
Here is a free library for keyboard handling http://www.codeproject.com/Tips/509810/Keyboard-Handling-in-iPhone-Applications. You need write just one line of code:
[AutoScroller addAutoScrollTo:scrollView];
Dont confuse with name AutoScroller. Purpose is same what you asked.