Jump to content

Autorotation & Positioning Problem


  • Please log in to reply
2 replies to this topic

#1
LooN3y

LooN3y

    InsanelyMac Protégé

  • Members
  • Pip
  • 29 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


Posted Image




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


Posted Image





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???

#2
TH3L4UGH1NGM4N

TH3L4UGH1NGM4N

    (~_~)

  • Retired
  • 1,159 posts
  • Gender:Male
  • Location:Wonderland
  • Interests:(~_^)
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

Posted Image

#3
LooN3y

LooN3y

    InsanelyMac Protégé

  • Members
  • Pip
  • 29 posts

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

Posted Image



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.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

© 2014 InsanelyMac  |   News  |   Forum  |   Downloads  |   OSx86 Wiki  |   Mac Netbook  |   PHP hosting by CatN  |   Designed by Ed Gain  |   Logo by irfan  |   Privacy Policy