LooN3y Posted October 5, 2012 Share Posted October 5, 2012 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 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 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??? Link to comment https://www.insanelymac.com/forum/topic/283381-autorotation-positioning-problem/ Share on other sites More sharing options...
TH3L4UGH1NGM4N Posted October 7, 2012 Share Posted October 7, 2012 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 Link to comment https://www.insanelymac.com/forum/topic/283381-autorotation-positioning-problem/#findComment-1858795 Share on other sites More sharing options...
LooN3y Posted October 10, 2012 Author Share Posted October 10, 2012 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 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. 1 Link to comment https://www.insanelymac.com/forum/topic/283381-autorotation-positioning-problem/#findComment-1859562 Share on other sites More sharing options...
Recommended Posts