Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

loon3y

macrumors 65816
Original poster
Oct 21, 2011
1,235
126
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:


Code:
- (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.


Code:
- (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???




resolved: i put it in the viewWillAppear like i have below



2njln6c.png
 
Last edited:

chown33

Moderator
Staff member
Aug 9, 2009
10,751
8,423
A sea of green
Code:
- (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???

UIInterfaceOrientationPortrait is a constant. Being constant, it never changes (by definition; it's constant). So the if condition always has the same result.

You should review how orientation-changes are actually detected. The relevant method starts with willRotate. Look for the heading "Orientation Changes ...":
http://developer.apple.com/library/...ges/RespondingtoDeviceOrientationChanges.html
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.