in iPhone App set focus on textView - iphone

In my iPhone App I have put textField and TextView both
and I have grouped them with scrollview
now the problem is when I call
[textField becomeBecomeFirstResponder];
it sets focus on textField in scrollView and makes content Area visible in scrollView accordingly
But When I do same thing with UItextView:
[textView becomeBecomeFirstResponder];
it does not make TextView visible in scroll view i.e it does not focus on textView (cursor sets on text view but content area of scrollview dose not appear with out manual scrolling)
What shoud I do to set focus on textView and set content area accordingly in in scrollview?

I believe your trouble here is that UITextView is a UIScrollView, while UITextField is a UIControl.
It is quite likely, though I have not tested this in code at the moment, that the best way to handle this is to watch for textView.isFirstResponder and when true, call [scrollView scrollRectToVisible:textView.frame animated:YES] on your UIScrollView.

Be sure u have set textView's delegate.

Related

UITextView displays keyboard only after touching in particular area?

When I increase the frame of UITextView based on content size programmatically in keyboard hide notification delegate method,
The textview height is increased perfectly.But when I touch the UITextView bottom line, the keyboard is not coming.If i touch the area which was before
increasing frame or in actual first frame area, the keyboard is coming.How can I enable userinteraction in all area of UITextView?
Textview is as scrollview<---view1<---view2<---UItextview
Even If i increase the height of view2 and UItextview in xib, the same problem is coming.
I have disabled scrolling facility of UITextview
After increase the height of your UITextView write this bellow line , may be its problem that some view is front of UITextView...
[self.view bringSubviewToFront:yourTextView];

How do I stop a UIScrollView from automatically scrolling when a UITextField is touched out of the scrollview's frame?

By default, if a textfield is a child of a scrollview and is touched when it is partially outside of the frame of the parent scrollview, the scrollview scrolls up a little. For example, let's say we have a scroll view with a frame height of 200, but a contentSize height of 260 and we put a text field at position 220. Now I scroll up and position the textfield half inside of the scrollview's frame and let the other half get cut off. If I touch this textfield, I notice that the scrollview automatically scrolls up by a couple pixels before the keyboard comes up. This is problematic because I already have my own scrolling code, so when this happens, it ends up scrolling twice as far as I want it to. Is there any way to remove this default behavior?
It sounds like your scrollview is getting moved in response to the keyboard showing instead of the text field being tapped. Take a look at Apple's Managing the Keyboard documentation; it has a helpful section on scrollviews.
A similar question already has been answered here:
https://stackoverflow.com/a/5673026/550177
You can also try to reset the scrollview's contentOffset when the textfield becomes first responder. Implemement the text field delegate like this:
-(void)textFieldDidBeginEditing:(UITextField *)textField
{
[self.scrollView setContentOffset:_scrollView.contentOffset animated:NO];
}
This code removes that automatic animation when the textfield is selected. I've tested with iOS 6.1 in the simulator.

scrollview and textview problem with scrolling iphone

i have a view, then in the view i have a scrollview and then in the scrollview i have a bunch of different objects. These objects aren't bigger than the scrollview's size, so i put a textView with a lot of text in the scrollview to see if it works but it is not scrolling. I deactivated the textview's scroll function. Does the scrollview knows the size of my textview? The textview's text is being set programmatically. Here's my view hierarchy:
Thanks in advance.
If you set the text programatically (and the size of the textview I assume since you don't scroll in it) you will have to set the contentSize of the scrollview after that. It doesn't automagically know when one of its elements grow.
And also set
scrollView.scrollEnabled = YES;

label and scroll view

HI FRIENDS..
I use a scroll view and a label now i want that when i scroll that , label also scroll with that and set to next location , i set paging enable = YES , so i want that there are 5 images and when i did scrolling the label i set is also move and show in other position.
thanks
To scroll a UILabel (or anything for that matter) WITH a UIScrollView, simply add the label to the UIScrollView.
You can easily do this in Interface Builder by the obvious methods.
You can also do this programmatically by utilizing the addSubview: method.
You can do one thing you change frame of label when you scroll in delegate method of scrollview or you can also make 5 same label in all 5 pages.
Good Luck
Well if you have added a scrollview on top of a uiview you can add that label on the view and then bring it to front. then you dont have to worry about changing frame of the uilabel as it will be always on top of the scrollview and at the same position and also you can change the text of that label when the user scrolls in pagecontrol value changed method.

Why a uitextfield inside a uiscroll view doesn't scroll?

I have a scrollview which contains a text field and a text view. I would that both two scrolled together. How can I do? Now only the text view scroll.
Precisely, I would that the title scrolls up while the user writes in the textview and, if the user decides to set it, he can scrolls up and refind the textfield.
Thanks
try this
in .h
IBOutlet UIScrollView *scrollView;
and connect it in the interface builder
and in your .m file put this into your viewDidLoad
[scrollView setScrollEnabled:YES];
[scrollView setFrame:CGRectMake(0,55,320,180)];
[scrollView setContentSize:CGSizeMake(320,320)];
then put your textField and your textView inside the scroolView in the interface builder
I want to say one thing,
Here the textfield can have only one line and the textview has multi-line of data.
So in your contest both will scroll, but you are saying one is scrolling and other is not.
In this what I am expecting is scrollview is not scrolling but the text view is showing its data(content).
Thats it.
If you want to check this, increase the textview frame upto its content and put userInteractionEnabled as NO and then set the scrollview content size to some what more than the textview size. Then you can observe both are scrolling.
Regards,
Satya