Jump to content
InsanelyMac Forum
Sign in to follow this  
LooN3y

Autorotation & Positioning Problem

Recommended Posts

On my app i found this problem, when in landscape mode and i select an item which leads to another view, my description doesn't show up.

 

 

but when im in portrait view and i select the item, and than i rotate it, THEN for some reason my description shows:

 

 

heres the a photo of the view when i use the app in landscape mode only

 

 

m3rk8.png

 

 

 

 

heres the photo of the view, when i use the app in portrait mode and than rotate it to landscape when im at this view. so you guys have some type of idea what im talking about

 

 

2lcvdz9.png

 

 

 

 

 

heres my coding:

 

 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
//return (interfaceOrientation == UIInterfaceOrientationPortrait);

if ([[uIDevice currentDevice]userInterfaceIdiom]==UIUserInterfaceIdiomPhone)
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
else
{
if (UIInterfaceOrientationIsPortrait(interfaceOrientation))
{
// Portrait frames
view_style_descript.frame = CGRectMake(0, 664, 768, 90);
view_Washing_Intrn.frame=CGRectMake(0, 753, 768, 158);
//[self RemoveSubView];
//view_color.frame = CGRectMake(710, 80, view_color.frame.size.width, view_color.frame.size.height);
}
else
{
// Landscape frames
view_style_descript.frame = CGRectMake(465, 200, 560, 90);
view_Washing_Intrn.frame=CGRectMake(465, 290, 560, 250);
// [self RemoveSubView];
//view_color.frame = CGRectMake(965, 80, view_color.frame.size.width, view_color.frame.size.height);
}

return YES;
}
}



- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{

if ([[uIDevice currentDevice]userInterfaceIdiom]==UIUserInterfaceIdiomPad)
{
if (UIInterfaceOrientationIsPortrait(toInterfaceOrientation))
{
// Portrait frames
view_style_descript.frame = CGRectMake(0, 664, 768, 90);
view_Washing_Intrn.frame=CGRectMake(0, 753, 768, 158);


if(ShowColor==FALSE)
{
view_color.frame = CGRectMake(710, 80, view_color.frame.size.width, view_color.frame.size.height);
}
else
{
view_color.frame = CGRectMake(665, 80, view_color.frame.size.width, view_color.frame.size.height);
}
}
else
{
// Landscape frames
view_style_descript.frame = CGRectMake(465, 200, 560, 90);
view_Washing_Intrn.frame=CGRectMake(465, 290, 560, 250);
if(ShowColor==FALSE)
{
view_color.frame = CGRectMake(965, 80, view_color.frame.size.width, view_color.frame.size.height);
}
else
{
view_color.frame = CGRectMake(925, 80, view_color.frame.size.width, view_color.frame.size.height);
}
}

}

}

 

 

 

these do not work, i tried using the If statement on viewDidLoad, but it doesn't know if its in portrait mode or landscape.

 

 

- (void)viewDidLoad
{
[super viewDidLoad];


if (UIInterfaceOrientationPortrait)
{
// Portrait frames
view_style_descript.frame = CGRectMake(0, 664, 768, 90);
view_Washing_Intrn.frame=CGRectMake(0, 753, 768, 158);
//[self RemoveSubView];
//view_color.frame = CGRectMake(710, 80, view_color.frame.size.width, view_color.frame.size.height);
}
else
{
// Landscape frames
view_style_descript.frame = CGRectMake(465, 200, 560, 90);
view_Washing_Intrn.frame=CGRectMake(465, 290, 560, 250);
// [self RemoveSubView];
//view_color.frame = CGRectMake(965, 80, view_color.frame.size.width, view_color.frame.size.height);
}

}

 

so basically if i put a "!" infront of UIInterfaceOrientationPortrait it executes the else statement, if not than the if.

 

 

anyone have any suggestions or advice???

Share this post


Link to post
Share on other sites
Advertisement

When you normally look to check if the orientation, there is the type def UIDeviceOrientation that you can use and set equal to your current UIDevice orientation. I just churned out a sample code of it in Xcode a while ago to show you

 

Screen%20Shot%202012-10-06%20at%2010.33.54%20PM.png

Share this post


Link to post
Share on other sites

When you normally look to check if the orientation, there is the type def UIDeviceOrientation that you can use and set equal to your current UIDevice orientation. I just churned out a sample code of it in Xcode a while ago to show you

 

Screen%20Shot%202012-10-06%20at%2010.33.54%20PM.png

 

 

thanks for the example!

 

 

i basically just put the original coding in to my viewdidload to get a short term fix, but thanks for the example, i do need to do it the right way for the long run.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.



×