I am a little puzzled by your code, so I really suggest starting from the beginning. As Lucia noted, there is no reason to recreate the HomeViewController. I am also puzzled by the [[self self]] abstract]; a little. This is not necessary if you are not doing something wrong elsewhere.
So, I would start with this ... In the app: didFinishLaunchingWithOptions: do something like this:
- (BOOL) application: (UIApplication *) application didFinishLaunchingWithOptions: (NSDictionary *) launchOptions
{
HomeViewController * home = [[[[HomeViewController alloc] init] autorelease];
UINavigationController * navController = [[[[UINavigationController alloc] initWithRootViewController: home] autorelease];
[self.window addSubview: navController.view];
}
Your navigation controller will be saved in the window, and the navigation controller will save your HomeViewController.
Then in motion Ended: withEvent: do something like:
- (void) motionEnded: (UIEventSubtype) motion withEvent: (UIEvent *) event
{
if (event.subtype == UIEventSubtypeMotionShake)
{
[self.navigationController popViewControllerAnimated: YES];
}
}
It should be.
If this does not work, can you give any other information? For example, does HomeViewController (and return YES) implement in shouldAutorotateToInterfaceOrientation :? If so, can you return no, so it does not rotate, since your first line reads: "Home browsing only supports portrait"?
Edit: example willRotateToInterfaceOrientation:duration: and didRotateFromInterfaceOrientation:
In the header for any controller, you detect jolts by adding a boolean:
BOOL isRotating;
In your implementation file, add two UIViewController methods that we want to override, for example:
- (void) willRotateToInterfaceOrientation: (UIInterfaceOrientation) toInterfaceOrientation duration: (NSTimeInterval) duration {
[super willRotateToInterfaceOrientation: toInterfaceOrientation duration: duration];
isRotating = YES;
}
- (void) didRotateFromInterfaceOrientation: (UIInterfaceOrientation) fromInterfaceOrientation {
[super didRotateFromInterfaceOrientation: fromInterfaceOrientation];
isRotating = NO;
}
Now do something similar for the event handler:
- (void) motionEnded: (UIEventSubtype) motion withEvent: (UIEvent *) event
{
if (event.subtype == UIEventSubtypeMotionShake &&! isRotating)
{
[self.navigationController popViewControllerAnimated: YES];
}
}