Proximity demo. I have a warning

Hi . I try to present a ViewController when i m in Case "immediate".
But when i the view is loaded, i have a warning :

2014-03-13 02:44:26.017 ProximityDemo[856:60b] Warning: Attempt to present <PresentProductViewController: 0x155915b0> on <ESTViewController: 0x156838d0> whose view is not in the window hierarchy!

Why ?

Also when i m on the new View , i would like to pop to old view when i m in Case "Near" , so i suppose i have to implement all the the code in the new ViewController ( presentProductViewController)

Here is my code :

ESTViewController :

switch (self.selectedBeacon.proximity)
{
case CLProximityUnknown:
{
labelText = [labelText stringByAppendingString: @"Unknown"];
break;
}
case CLProximityImmediate:
{
labelText = [labelText stringByAppendingString: @"Immediate"];

            PresentProductViewController *showViewController = [[PresentProductViewController alloc] initWithNibName:@"PresentProductViewController" bundle:nil];

            [self presentViewController:showViewController animated:YES completion:nil];

            break;
        }
        case CLProximityNear:
        {
            labelText = [labelText stringByAppendingString: @"Near"];
            break;
        }
        case CLProximityFar:
        {
            labelText = [labelText stringByAppendingString: @"Far"];
            break;
        }

        default:
            break;
    }

PresentProductViewController :

switch (self.selectedBeacon.proximity)
{
case CLProximityUnknown:
{
labelText = [labelText stringByAppendingString: @"Unknown"];
break;
}
case CLProximityImmediate:
{
labelText = [labelText stringByAppendingString: @"Immediate"];
break;
}
case CLProximityNear:
{
labelText = [labelText stringByAppendingString: @"Near"];
break;

// I tryed the 2 way here but that dont work.

     //ESTViewController *initViewController = [[ESTViewController alloc]init];
            //[self presentViewController:initViewController animated:YES completion:nil];

            //[self.navigationController popToRootViewControllerAnimated:YES];



        }
        case CLProximityFar:
        {
            labelText = [labelText stringByAppendingString: @"Far"];
            break;
        }

        default:
            break;
    }

Please check the answer to your question here:
http://stackoverflow.com/questions/22368042/estimote-beacons-proximity-demo-pushing-a-viewcontroller-on-immediate-case

LOL Its my question on stackoverflow. But i ts ok i found a solution.

Now my problem is to pop to view controller if i turn off the beacon.

this code dont work correctly :

case CLProximityUnknown:
        {
            self.labelText.text = [self.labelText.text stringByAppendingString: @"Unknown"];

            [self.navigationController popToRootViewControllerAnimated:YES];
            break;
        }

Can you help please ?

Hi again!

If you're using the "presentViewController" method, you must use the "dismissViewController" method, inside the presented view controller, to hide it.

If you're using navigationController you should use "pushViewController: animated:" method instead of "presentViewController".

Let me know, if that helped.