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 11-16-2008, 07:08 AM   #5 (permalink)
Forsworn
Registered Member
 
Forsworn's Avatar
 
Join Date: Oct 2008
Location: Germany
Posts: 504
Forsworn is on a distinguished road
Default

Okay... here's the working code:

Setup:

Interface:
View:
-NavigationBar
-(ImageView,etc.)
-ScrollView:
.......... -TextFields,etc.

ViewController:
Code:
IBOutlet UIScrollView *scrollView;
Connect:
- The view outlet to your 'main' view (not the scrollview!)
- The textFields' delegates to your viewController
- The scrollView Outlet to your Scrollview

In the implementation you have to add the following delegate methods:

Code:
-(void)textFieldDidBeginEditing:(UITextField *)textField {
	NSLog(@"preparing to show keyboard");
	scrollView.frame = CGRectMake(0,44,320,200); //44:NavigationBar ; 200: Keyoard
	[scrollView scrollRectToVisible:textField.frame animated:YES]; //Oddly enough, it only works with the animation...
	
}
Code:
-(void)textFieldDidEndEditing:(UITextField *)textField {
	NSLog(@"prepare to hide keyboard");
	scrollView.frame = CGRectMake(0,44,320,416); //original setup
}
I hope this will help somebody.

Last edited by Forsworn; 02-10-2009 at 11:36 AM.
Forsworn is offline   Reply With Quote
 

» Advertisements
» Online Users: 389
11 members and 378 guests
7twenty7, antonwilliams, Arty Tales, DaveDee, demas, erdinc27, gogoman, Lily.P, MarkC, roof44, ryantcb
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,594
Threads: 94,083
Posts: 402,778
Top Poster: BrianSlick (7,990)
Welcome to our newest member, kopmlop
Powered by vBadvanced CMPS v3.1.0

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