Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-05-2010, 06:40 AM   #1 (permalink)
Registered Member
 
Join Date: Jul 2010
Location: Germany - Karlsruhe
Posts: 5
jcdmb is on a distinguished road
Default How to make UITextView scroll up when entering it?

Hi,

I have a UITextView included in a UITableViewCell. The layout is correct when the views are initially displayed, but once I click in the UITextView it DOES NOT automatically scrolls up and the keyboard stays in front of the UITextView so that I can't see what I am typing. I have to scroll the view manually to see what I am typing.

This image is when the UITextView is not active:


And this one is when I clicked in the UITextView to make it active:


I want the cell with the UITextView to scroll up. How can I achieve this?

Any suggestions are appreciated.

Julio Cezar
jcdmb is offline   Reply With Quote
Old 07-05-2010, 06:59 AM   #2 (permalink)
Fly-by-night Innovator
 
Join Date: Jun 2010
Posts: 364
musicwind95 is on a distinguished road
Default Notifications

You'll probably have to resort to notifications. See here: (you may have to scroll up)

Apple - Support - Discussions - AddressBook style table cells? (iOS 4.0) ...
musicwind95 is offline   Reply With Quote
Old 07-05-2010, 08:10 AM   #3 (permalink)
Registered Member
 
Join Date: Jul 2010
Location: Germany - Karlsruhe
Posts: 5
jcdmb is on a distinguished road
Default It "almost" worked

Thanks for your reply musicwind95. It actually worked, but it works only for ONE case, that means, no matter which UITextView I click in, the view scrolls to the specific given point (in your example: (0, 480, 320, 60)). But I have many differents UITextViews on my table, and I want bring the view to scroll exactly at the bottom of a specific UITableView (that I clicked in) dynamically.

What would also work is to bring the cell with the UITextView to scroll to top.

I would appreciate any additional suggestions.

Thanks again for answering.

Last edited by jcdmb; 07-05-2010 at 08:38 AM.
jcdmb is offline   Reply With Quote
Old 07-05-2010, 08:51 AM   #4 (permalink)
Fly-by-night Innovator
 
Join Date: Jun 2010
Posts: 364
musicwind95 is on a distinguished road
Default

Quote:
Originally Posted by jcdmb View Post
Thanks for your reply musicwind95. It actually worked, but it works only for ONE case, that means, no matter which UITextView I click in, the view scrolls to the specific given point (in your example: (0, 480, 320, 60)). But I have many differents UITextViews on my table, and I want bring the view to scroll exactly at the bottom of a specific UITableView (that I clicked in) dynamically.

What would also work is to bring the cell with the UITextView to scroll to top.

I would appreciate any additional suggestions.

Thanks again for answering.
That CGRect was a very rough approximation; I just wanted to test the scrolling. You'll need to use tableView:didSelectRowAtIndexPath:, determine the section and row (using indexPath.section and indexPath.row) of the cell you've tapped on, and then set a CGRect according to the cell's current position. Figuring out that location is beyond me—I'm still working on counting it out, although there's probably a method that allows you to get the frame of the current cell. Check the docs.

Or, if you're happy with just counting, then use IB's third inspector (select something and press Command-3) to get the frame and location of items.
musicwind95 is offline   Reply With Quote
Old 07-05-2010, 09:20 AM   #5 (permalink)
Registered Member
 
Join Date: Jul 2010
Location: Germany - Karlsruhe
Posts: 5
jcdmb is on a distinguished road
Default

Hi musicwind97, I've already done it. My solution is not the best but it works very well: everything happens on tableView:cellForRowAtIndexPath:

1) For every cell that has a UITextView I have a NSDictionary: I save all my UITextView's on the cells on NSDictionary with a particular key.

2) And I also have another NSDictionary with the indexPath objects that are created in tableView:cellForRowAtIndexPath. If a cell A has UITextView A, they will have the same key in the NSDictionaries.

3) I implement the UITextViewDelegate and call textViewDidBeginEditing: here is my code:
- (void)textFieldDidBeginEditing: (UITextField *)textField {
NSArray *keys = [self.answersDic allKeysForObject:textField];
id *key = (id *)[keys objectAtIndex:0];
NSIndexPath *tempIndex=[self.indexPathForViews objectForKey:key];
[tableViewLocal scrollToRowAtIndexPath:tempIndex atScrollPosition:UITableViewScrollPositionTop animated:YES];
}

OBSERVATIONS:
a) answersDic is the NSDictionary where my UITextViews are saved.
b) indexPathForViews is the NSDictionary where my IndexPaths are saved.
c) the most important part of this code: the method, that brings the view to scroll up:
[tableViewLocal scrollToRowAtIndexPath:tempIndex atScrollPosition:UITableViewScrollPositionTop animated:YES];

So, thats it. Thanks for your help!
jcdmb is offline   Reply With Quote
Reply

Bookmarks

Tags
iphone, scroll up, uitextview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 327
6 members and 321 guests
anothermine, Chickenrig, givensur, michaelhansen, PixelInteractive, stanny
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,118
Posts: 402,892
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 12:27 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0