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 05-19-2009, 08:12 AM   #1 (permalink)
New Member
 
Join Date: May 2009
Posts: 37
Knuckles is on a distinguished road
Default Several problems with UITableView & embedded UITextView

Hello all!

I have several problems with a UITextView object embedded in a UITableViewCell.

How should I do to detect that the user has touched outside my UITextView to hide the keyboard when the user edits it?

Also, when user types his message and enters multiple line, the textview scrolls and hide the previous lines (but my textview has a correct size). How can I do to disable this type of scrolling?

Thank you in advance!
Knuckles is offline   Reply With Quote
Old 05-19-2009, 09:23 AM   #2 (permalink)
Apple Evangelist
 
sukumar_77's Avatar
 
Join Date: Aug 2008
Location: Mumbai
Posts: 203
sukumar_77 is on a distinguished road
Default

Subclass UITableViewCell and overright following method.

Code:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
On touch, detect the current location and validate it against the UITextView's frame (i.e whether it lies inside the frame or not). Call following statement to hide the keyboard.

Code:
[myTextView resignFirstResponder];
You will have to specify number of lines as follows.

Code:
myTextView.numberOfLines = 2; //
The scrolling will be done automatically if the number of lines will be more than 2 and yes, it depends on the height of the texview also.
__________________
- Sushil
sukumar_77 is offline   Reply With Quote
Old 05-19-2009, 09:38 AM   #3 (permalink)
New Member
 
Join Date: May 2009
Posts: 37
Knuckles is on a distinguished road
Default

Quote:
Originally Posted by sukumar_77 View Post
Subclass UITableViewCell and overright following method.

Code:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
On touch, detect the current location and validate it against the UITextView's frame (i.e whether it lies inside the frame or not). Call following statement to hide the keyboard.

Code:
[myTextView resignFirstResponder];
You will have to specify number of lines as follows.

Code:
myTextView.numberOfLines = 2; //
The scrolling will be done automatically if the number of lines will be more than 2 and yes, it depends on the height of the texview also.
Okay I will subclass UITableViewCell and use the above method.

UITextView doesn't have numberOfLines property, it's not a UILabel, that's my problem.
Knuckles is offline   Reply With Quote
Old 05-19-2009, 09:56 AM   #4 (permalink)
Apple Evangelist
 
sukumar_77's Avatar
 
Join Date: Aug 2008
Location: Mumbai
Posts: 203
sukumar_77 is on a distinguished road
Default

Yes, you are correct. Got confused about the numberOfLines method. My fault.
__________________
- Sushil
sukumar_77 is offline   Reply With Quote
Old 05-19-2009, 11:01 AM   #5 (permalink)
New Member
 
Join Date: May 2009
Posts: 37
Knuckles is on a distinguished road
Default

Any solution to my problem? I just want to regulate the automatic scrolling.
Knuckles is offline   Reply With Quote
Old 05-21-2009, 07:00 PM   #6 (permalink)
New Member
 
Join Date: May 2009
Posts: 1
thorstenbln is on a distinguished road
Default

Hi,

I had the same problem. Subclass UITextView and override setContentOffset:animated. That worked for me.

Regards
Thorsten
thorstenbln is offline   Reply With Quote
Old 08-01-2010, 11:11 PM   #7 (permalink)
Registered Member
 
Join Date: Aug 2010
Posts: 2
matthusselhuf is on a distinguished road
Default Senisble TableView

Thanks guys, I was finally able to get this working by using sensible tableview (http://www.sensiblecocoa.com)
matthusselhuf is offline   Reply With Quote
Reply

Bookmarks

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: 338
6 members and 332 guests
givensur, ipodphone, jbro, mer10, n00b, yomo710
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,113
Posts: 402,881
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

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