• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Newbie: UITextView in Landscape
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Newbie: UITextView in Landscape


  • Subject: Newbie: UITextView in Landscape
  • From: Arnold Nefkens <email@hidden>
  • Date: Fri, 14 May 2010 13:06:51 +0200

Hi List,

Still new to Cocoa...

In placed a new ViewController following the example in UICatalog. I got it working but was wondering how to make the view also editable in landscape view...

Below is the code to display the keyboard and hide the keyboard, which I supplemented with the if... else if statements.

- (void)keyboardWillShow:(NSNotification *)aNotification
{
	UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
	if (orientation == UIInterfaceOrientationPortrait) {
			// the keyboard is showing so resize the table's height
		CGRect keyboardRect = [[[aNotification userInfo] objectForKey:UIKeyboardBoundsUserInfoKey] CGRectValue];
		NSTimeInterval animationDuration = [[[aNotification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
		CGRect frame = self.view.frame;
		frame.size.height -= keyboardRect.size.height;
		[UIView beginAnimations:@"ResizeForKeyboard" context:nil];
		[UIView setAnimationDuration:animationDuration];
		self.view.frame = frame;
		[UIView commitAnimations];
	} else if (orientation == UIInterfaceOrientationLandscapeLeft) {
		NSLog(@"Left"); // Verijderen later
		CGRect keyboardRect = [[[aNotification userInfo] objectForKey:UIKeyboardBoundsUserInfoKey] CGRectValue];
		NSTimeInterval animationDuration = [[[aNotification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
		CGRect frame = self.view.frame;
		frame.size.height -= keyboardRect.size.height;
		[UIView beginAnimations:@"ResizeForKeyboard" context:nil];
		[UIView setAnimationDuration:animationDuration];
		self.view.frame = frame;
		[UIView commitAnimations];
	} else if (orientation == UIInterfaceOrientationLandscapeRight){
		NSLog(@"Right"); // verwijderen later.
		CGRect keyboardRect = [[[aNotification userInfo] objectForKey:UIKeyboardBoundsUserInfoKey] CGRectValue];
		NSTimeInterval animationDuration = [[[aNotification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
		CGRect frame = self.view.frame;
		frame.size.width -= keyboardRect.size.width;
		[UIView beginAnimations:@"ResizeForKeyboard" context:nil];
		[UIView setAnimationDuration:animationDuration];
		self.view.frame = frame;
		[UIView commitAnimations];
	}

}

I know that I have to change the line frame.size.hight -= keyboardRect.size.hight, but I cannot figure out into what....

If I change the line in the landscape left mode to: frame.size.width -= keyboardRect.size.width. The view works, but the statusbar is huge, and the right button is gone....

Into what do I have to change this line

Kind regards in advance

Arnold Nefkens

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: Encode a 'Class' type using NSValue
  • Next by Date: Finding which window is causing the "NSWindow does not support utility styleMask 0x10" error
  • Previous by thread: Re: TUTORIAL: Generating Unique ID Strings
  • Next by thread: Finding which window is causing the "NSWindow does not support utility styleMask 0x10" error
  • Index(es):
    • Date
    • Thread