Orientation cannot test on iPhone simulator?

Discussion in 'iOS Programming' started by Moon013, Aug 14, 2008.

  1. Moon013 macrumors newbie

    Jul 14, 2008
    I have this created under my viewdidload()

    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
    UIDeviceOrientation orientationType = [[UIDevice currentDevice] orientation];

    And i go about testing orientation by doing these in a function:

    if(orientationType == UIDeviceOrientationPortrait || orientationType == UIDeviceOrientationPortraitUpsideDown)
    testingLabel.text = @"ZOOM PORTRAIT DETECTED";
    else if (orientationType == UIDeviceOrientationLandscapeLeft || orientationType == UIDeviceOrientationLandscapeRight)
    testingLabel.text = @"ZOOM LANSCAPE DETECTED!";
    testingLabel.text = @"NONE";
    *testingLabel is linked correctly and tested*

    I test by going to the hardware->Rotate Left/ Rotate Right.

    And i will do something to call out the function. Upon called, the debugger show "NONE"

    Am i missing out something? Or it is just that I will need to test on an actual iPhone?
  2. gralem macrumors member

    Mar 25, 2002
    viewDidLoad only loads once when the view is instantiated. I'm not even sure UIDeviceOrientation is available during the viewDidLoad phase. There is a method called by the phone every time the orientation changes.

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;
    Put your code in there.


Share This Page