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

View Single Post
Old 01-27-2010, 10:45 AM   #1 (permalink)
dennis3484
Registered Member
 
Join Date: Aug 2009
Posts: 5
dennis3484 is on a distinguished road
Default Autoresize UITextView and UIScrollView

Hello guys,

I already did several searches on the Forum and Google, but I couldn't find a solution to my problem.

I have a Detail View for a product that includes a UIScrollView and a few subviews (UIImageView, UILabel, UITextView). You can find an example here.

First I wanna autoresize the UITextView (not the text itself!) to the corresponding height. Then I wanna autoresize the entire UIScrollView so that it fits the height of my UITextView and the elements above it. I've tried the following code:

Code:
myUITextView.frame = CGRectMake(2.0, 98.0, 316.0, self.view.bounds.size.height);

[scrollView setContentOffset:CGPointMake(0.0, 0.0) animated:NO];
scrollView.contentSize = CGSizeMake(320.0, 98.0 + [myUITextView frame].size.height);

[self.view addSubview:scrollView];
*98.0 + [myUITextView frame].size.height)* because my thought was: After getting the height of myUITextView, add the height of the other subviews (98.0) to it.

Unfortunately it doesn't work very well. Depending on the content of the UIScrollView, it is too short or too long. I did some logging with the result that the height of the UITextView is always the same:

Quote:
> 2010-01-27 14:15:45.096 myApp[1362:207] [myUITextView frame].size.height: 367.000000
Thanks!
dennis3484 is offline   Reply With Quote
 

» Advertisements
» Online Users: 485
17 members and 468 guests
AyClass, baja_yu, David-T, djbrooks111, djohnson, Free App Monster, HemiMG, HowEver, iacemomo, ilmman, linkmx, mezzh, simplymuzik3, SLIC, timle8n1, yomo710, yvonneolivia
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,439
Threads: 94,026
Posts: 402,591
Top Poster: BrianSlick (7,978)
Welcome to our newest member, mezzh
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:40 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.