If (interfaceOrientation = landscape){ ?

Discussion in 'iOS Development' started by Steaps, Jan 28, 2009.

  1. Steaps

    Steaps New Member

    Joined:
    Oct 24, 2007
    Messages:
    5,074
    Likes Received:
    41
    Device:
    iPod touch
    I need to check if the interfaceOrientation is in landscape mode, and i need it in an if statement.

    I haven't a clue, this is just to show my guess/describe what i mean or need.
    Code:
    if (UIInterfaceOrientation = Landscape) {
         // CODE HERE
    }
    
    I want to commit some animations, but only when the device is in landscape mode. Any help?

    Thanks, Stephen.4
  2. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55

    wait for it...

    Code:
    if(UIInterfaceOrientationIsLandscape)

    try that.
  3. NumNum

    NumNum New Member

    Joined:
    Oct 26, 2008
    Messages:
    233
    Likes Received:
    0
    Device:
    2G iPod touch
    And by the way, where you put CODE HERE, that's inside of a comment line (//), so just make sure you get rid of those two slashes.
  4. Steaps

    Steaps New Member

    Joined:
    Oct 24, 2007
    Messages:
    5,074
    Likes Received:
    41
    Device:
    iPod touch
    If i use that, i think it would need to be in the view controller though?
    I tried it in my MainView.m (Where i need to use it) and i get errors.
    Code:
    UIInterfaceOrientationIsLandscape' undeclared (first use in this function)
    I think i might just be doing something wrong. I need it in my MainView.m; inside the Bool:
    Code:
    - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
    {
    I know... I put it there so i don't have to post my whole code.
  5. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
  6. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    i foudn that in UIApplication.h i think.
  7. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    Wow, I reread the thread. You really should be using view controllers. When the device orientation changes, have your view controller control what happens. It's a simple concept really.

    Create a function in your view that the controller can call. If your view controller needs to do something to a text field, then when it rotates, have it call
    [yourTextField becomeFirstResponder];
  8. Steaps

    Steaps New Member

    Joined:
    Oct 24, 2007
    Messages:
    5,074
    Likes Received:
    41
    Device:
    iPod touch
    I'm on a mac, could someone please .ZIP that for me?
    I don't want to download any more programs

    Please Register or Log in to view images

    .

    Hmm, so i should have my function:
    Code:
    - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
    
    Inside the ViewController? And have [yourTextField becomeFirstResponder]; at the beginning of the function? I really have no clue what you mean

    Please Register or Log in to view images

    , just guessing really.
  9. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    No, man up and download 7zip. It uses a far superior compression algorithm to zip.

    http://www.7-zip.org/download.html
  10. Steaps

    Steaps New Member

    Joined:
    Oct 24, 2007
    Messages:
    5,074
    Likes Received:
    41
    Device:
    iPod touch
    I did right after i posted that, not sure why.
    But i edited my post above.

    EDIT: I needed this i believe:
    Code:
    -(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
    	if((self.interfaceOrientation == UIDeviceOrientationLandscapeLeft) || (self.interfaceOrientation == UIDeviceOrientationLandscapeRight)){
    
    	} else	if((self.interfaceOrientation == UIDeviceOrientationPortrait) || (self.interfaceOrientation == UIDeviceOrientationPortraitUpsideDown)){
    
    	}
    }
    

Share This Page