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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.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 10-04-2009, 03:58 AM   #1 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 26
Default UITextView Resizing Problem

Hi everyone,
I have a UITextView that I've created programmatically and manually added as a subview to a UIView. When I click on the UITextView, the keyboard appears and the UITextView gets resized to fit inside the smaller screen real estate. My problem arises when I dismiss the keyboard. For whatever reason, I can't get the UITextView to refill the entire screen.

I'm resize the text view by changing the frame from within the keyboardWillShow and keyboardWillHide notifications. The first resize (when keyboardWillShow is called) seems to work fine, but the second resize (when keyboardWillHide is called) apparently does nothing.

Does anyone know why this isn't working? Are there any alternatives to make this happen? My code is below. Thanks for any help you guys can offer!


Code:
- (void)loadView
{

	textView = [[UITextView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.bounds.size.width, self.view.bounds.size.height)];  
	textView.delegate = self;
	textView.backgroundColor = [UIColor whiteColor];
	textView.scrollEnabled = YES;
	
	// this will cause automatic vertical resize when the table is resized
	textView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;

[self.view addSubview:containerView];

}

- (void)viewWillAppear:(BOOL)animated
{	
	
	// watch the keyboard
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) 
												 name:UIKeyboardWillShowNotification object:self.view.window]; 

	// watch the keyboard
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) 
												 name:UIKeyboardWillHideNotification object:self.view.window]; 
	
	
}



- (void)keyboardWillShow:(NSNotification *)notif
{
	// The keyboard will be shown. Modify the textView size to fit the smaller screen.	
	textView.frame = CGRectMake(0.0, 0.0, self.view.bounds.size.width, 200);

	
}

- (void)keyboardWillHide:(NSNotification *)notif
{
	// The keyboard will be shown. Modify the textView size to fit the larger screen.
	textView.frame = CGRectMake(0.0, 0.0, self.view.bounds.size.width, 400);
	
}
borg359 is offline   Reply With Quote
Reply

Bookmarks

Tags
dismiss, keyboard, resizing, 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: 235
16 members and 219 guests
@sandris, ADY, Alsahir, dacapo, Dani77, djohnson, HemiMG, jansan, JasonR, MarkC, mer10, prchn4christ, ryandb2, smethorst, tomtom100
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,882
Threads: 89,228
Posts: 380,762
Top Poster: BrianSlick (7,129)
Welcome to our newest member, jansan
Powered by vBadvanced CMPS v3.1.0

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