0

I am newbie for iPhone application. Below is what I have...

enter image description here

When I enter Item name, I get proper screen with Done option. When I click Done, keyboard get hided.

enter image description here

Same happen for Time also.

Now when I click on description and type something, I get screen as below.

enter image description here

Now my problem is, I can't see UITextView and because of that I can't see what I am typing.

How can I show the UITextView so that I can see what I am typing.


Update 1

enter image description here

Fahim Parkar
  • 30,974
  • 45
  • 160
  • 276
  • 2
    That is a design problem, you shouldn't put the textview there. But maybe you can use a UIScrollerView, it might scroll the view, so you can see the text while you are writing. – jcesarmobile Jan 08 '13 at 13:21

4 Answers4

8

First take these whole controls in UIScrollView and set as it is,

after just in UITextView delegate method textViewDidBeginEditing set the frame of view like bellow...

-(void)textViewDidBeginEditing:(UITextView *)textView
{
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.3];
    yourScrollView.frame = CGRectMake(yourScrollView.frame.origin.x, -160, yourScrollView.frame.size.width, yourScrollView.frame.size.height);
    [UIView commitAnimations];

}

and also set same like before after return like bellow...

-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
    if ([text isEqualToString:@"\n"]) 
    {
        [textView resignFirstResponder];
        [UIView beginAnimations:nil context:NULL];
        [UIView setAnimationDuration:0.3];

        yourScrollView.frame = CGRectMake(yourScrollView.frame.origin.x, 0, yourScrollView.frame.size.width, yourScrollView.frame.size.height);
        [UIView commitAnimations];
        return NO;
    }
    return YES;
}

you can also set the frame of UIView instead of UIScrollView..

Also first give the Delegate to UITextView and add this delegate in .h file

i hope this helpful to you...

Paras Joshi
  • 20,427
  • 11
  • 57
  • 70
  • i think this will be good option against uiscrollview... i will check tomorrow and get. back to you incase of any queries... – Fahim Parkar Jan 08 '13 at 13:44
  • sure post comment if you get any query.. :) – Paras Joshi Jan 09 '13 at 04:47
  • how can I set the scroll bar to visible of the scrollview? – Fahim Parkar Jan 09 '13 at 07:13
  • what I want is when I focus on description textarea, I want to see Scroller i.e. white line for scrolling up and down... – Fahim Parkar Jan 09 '13 at 07:18
  • oh you mean you want to see the scroller on uitextview?? then its displayed automatically when you data in uitextview is more then the frame of uitextview .. but here for that uitextview's ShowsVerticalScrollers property must checked.. – Paras Joshi Jan 09 '13 at 07:23
  • no, not in textview. When I am using UIScrollView, I was under impression that I will see scrollbar at the right side, however I don't see. Now what I want is, when I click on UITextView, I can see UIScrollView scroll bar... I hope you get now... – Fahim Parkar Jan 09 '13 at 07:25
  • just in viewDidLoad method try to set some contentOffset of scrollview then check it.. i.e [scrView setContentSize:CGSizeMake(320, 500)]; – Paras Joshi Jan 09 '13 at 07:27
  • I will update the question... I added `[myScrollView setContentSize:CGSizeMake(300, 340)];`, still that is not solving problem. Once I update question, I will let you know – Fahim Parkar Jan 09 '13 at 07:42
  • @FahimParkar hey dude post new quetion instead of update the quetion its good for more info from another user also so... – Paras Joshi Jan 09 '13 at 07:45
  • @FahimParkar hey just see dude what i want to say that for that you can just descrese the height of scrollview and set contentoffset here dude... – Paras Joshi Jan 09 '13 at 07:48
  • and also set contentOffSet more than the height of scrollview and you will see the scroller when you just scroll the scrolllview after automatically its unvisible.. – Paras Joshi Jan 09 '13 at 07:50
  • Why I want scrollview is if I don't want to write in textview how can I go back to other textfield? – Fahim Parkar Jan 09 '13 at 07:51
  • like every application user click the return key of keyboard and you got normal uiscrollview which you see at starting or before the textview become editing so.. now got it dude?? – Paras Joshi Jan 09 '13 at 07:52
  • can you take a look at [this question](http://stackoverflow.com/questions/14235433/how-to-find-the-row-detail-of-uitableviewcell) – Fahim Parkar Jan 09 '13 at 12:43
2

set following code in viewDidLoad for key board hide/show notification

  [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardWasShown:)
                                                 name:UIKeyboardDidShowNotification object:nil];

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardWillBeHidden:)
                                                 name:UIKeyboardWillHideNotification object:nil];

and set this method and change the frame of view in this code

- (void)keyboardWasShown:(NSNotification *)aNotification
{

}

- (void)keyboardWillBeHidden:(NSNotification *)aNotification
{

}
Pratik B
  • 1,599
  • 1
  • 15
  • 32
1

Put all the content in a UIScrollView and use the scrollRectToVisible:animated: to scroll to the correct TextField when it is active.

Also you have to resize the scrollview according to if the keyboard is shown or not, so you need to set up TextField delegates

Roland Keesom
  • 8,180
  • 5
  • 45
  • 52
1

Used UIScrollView in design behind all controls & set the contentsize of it on beginEditing of TextView or TextFieldShouldReturn of second(time) textfield.

Girish
  • 4,692
  • 4
  • 35
  • 55