Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Nnavick

macrumors regular
Original poster
Oct 13, 2010
100
0
In the SMS app or other app that using a keyboard,
When you press on the TextFiled the keyboard is
coming up and the view same as the keyboard.
My question is if this is a simple animation that change
The view xcordinates or it's built in function?

Thank you and have a nice weekend !
 

dantastic

macrumors 6502a
Jan 21, 2011
572
678
funny you should mention it, I just did that in a tableview for my app :)

Code:
whateverCausedTheKeyboardToPopUp {
	
	[UIView beginAnimations: @"anim" context: nil];
	[UIView setAnimationBeginsFromCurrentState: YES];
	[UIView setAnimationDuration: 0.3f];
	[self.tableView setContentOffset:CGPointMake(0.0, [tableViewArray count] - 1 * 44)];
	self.tableView.frame = CGRectOffset(self.tableView.frame, 0, -kKeyboardOffset);
	[UIView commitAnimations];

If you've a uiview with a textfield you may want to get rid of the setcontentoffset and change the self.tableview.frame to self.view.frame.

don't forget to do a
Code:
 self.tableView.frame = CGRectOffset(self.tableView.frame, 0, kKeyboardOffset);
when you're done with the keyboard.
 

Nnavick

macrumors regular
Original poster
Oct 13, 2010
100
0
funny you should mention it, I just did that in a tableview for my app :)

Code:
whateverCausedTheKeyboardToPopUp {
	
	[UIView beginAnimations: @"anim" context: nil];
	[UIView setAnimationBeginsFromCurrentState: YES];
	[UIView setAnimationDuration: 0.3f];
	[self.tableView setContentOffset:CGPointMake(0.0, [tableViewArray count] - 1 * 44)];
	self.tableView.frame = CGRectOffset(self.tableView.frame, 0, -kKeyboardOffset);
	[UIView commitAnimations];

If you've a uiview with a textfield you may want to get rid of the setcontentoffset and change the self.tableview.frame to self.view.frame.

don't forget to do a
Code:
 self.tableView.frame = CGRectOffset(self.tableView.frame, 0, kKeyboardOffset);
when you're done with the keyboard.


what value did you set for
"kKeyboardOffset"?
 

dantastic

macrumors 6502a
Jan 21, 2011
572
678
It will depend on the type of keyboard and screen orientation.

for my app a value of 215 does the trick.
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
The height of the keyboard will vary with different orientations and maybe with different language keyboards. The height of the keyboard is sent in the notification posted when the keyboard appears. You should read it from there and use that value.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.