Re: iOS: Manually setting orientation makes a mess out of my interface
Re: iOS: Manually setting orientation makes a mess out of my interface
- Subject: Re: iOS: Manually setting orientation makes a mess out of my interface
- From: Development <email@hidden>
- Date: Sat, 04 Jun 2011 22:33:51 -0700
k.. at this point I'm begging
can any one tell me how to shift from portrait to landscape and back again.
I know this is possible I see it in games all the time.
On Jun 4, 2011, at 8:31 PM, Development wrote:
> Ok
>
> when my application first starts up I want it in portrait mode. However when a user switches to an editor it needs to transform in to landscape mode.
>
> I have this working more or less correctly.
>
> However, when I leave the editor, it switches back to portrait amd all of the portrait views are a mess.
>
> I was able to get the very first portrait view to display correctly.
> But when I switch to a new portrait view it has been resized to 460px high. And no matter what I do I absolutely cannot set it back to the correct 480px high.
> nor can I get it to display lower on the screen to correct the display
>
> I've attempted to change both the bounds and frame and nothing happens it seems to have become read only.
>
> How does one correct view sizes and origins when switching back from a manually set orientation to the original one?
>
> this is my rotator:
>
> -(void)rotateMainViewToOrientation:(UIDeviceOrientation)orientation
> {
>
>
> [UIView beginAnimations:@"View Flip" context:nil];
> [UIView setAnimationDuration:.5];
> [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
>
> [[UIApplication sharedApplication] setStatusBarHidden:NO animated:NO];
>
> [[UIApplication sharedApplication]setStatusBarOrientation:orientation];
> //NSLog(@"2");
>
> CGPoint newOrig =CGPointMake(0.0, 0.0);
> int dir = 90;
> if(!ISIPAD){
> if (orientation == UIDeviceOrientationLandscapeLeft || orientation == UIDeviceOrientationLandscapeRight){
> if (orientation == UIDeviceOrientationLandscapeRight) {
> dir = 270;
> }
> self.view.frame = CGRectMake(0.0, 0.0, 480, 320);
> self.view.center = CGPointMake(160.0f, 240.0f);
> }
> else{
>
>
> if(self.view.frame.size.width >320){
> //does nothing
> newOrig.x = -80;
> newOrig.y = 80;
>
>
> }
> self.view.center = CGPointMake(240.0f, 160.0);
> if(orientation == UIDeviceOrientationPortrait){
> dir = 0;
> }
> else{
> dir = 180.0;
> }
> }
> }
> else {
> if (orientation == UIDeviceOrientationLandscapeLeft || orientation == UIDeviceOrientationLandscapeRight){
> if (orientation == UIDeviceOrientationLandscapeRight) {
> dir = 270;
> }
> else dir = 90;
> self.view.frame = CGRectMake(0.0, 0.0, 1024, 768);
> self.view.center = CGPointMake(1024.0/2.0f, 768.0/2.0f);
> }
> }
> self.view.transform = CGAffineTransformIdentity;
> self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(dir));
> self.view.transform = CGAffineTransformTranslate(self.view.transform, newOrig.x, newOrig.y);
>
> [UIView commitAnimations];
> }_______________________________________________
>
> 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
_______________________________________________
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