Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm a bit puzzled by your code so I'd really suggest starting from the beginning. As Lukya mentioned, there's no reason to recreate the HomeViewController. I'm also baffled by the "[[self retain] autorelease];" bit. That shouldn't be necessary unless you're doing something incorrectly elsewhere.</p> <p>So I would start with this... In application:didFinishLaunchingWithOptions: do something like this:</p> <pre> - (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]; } </pre> <p>The window will retain a your nav controller and the nav controller will retain your HomeViewController.</p> <p>Then in motionEnded:withEvent: do something like:</p> <pre> - (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event { if (event.subtype == UIEventSubtypeMotionShake) { [self.navigationController popViewControllerAnimated:YES]; } } </pre> <p>That should be it.</p> <p>If that does not work then can you give any other info? For example, does HomeViewController implement (and return YES) in shouldAutorotateToInterfaceOrientation:? If so, can you return no so it doesn't rotate since your first line says "Home view Only supports portrait"?</p> <p>Edit: An example of <code>willRotateToInterfaceOrientation:duration:</code> and <code>didRotateFromInterfaceOrientation:</code> as well.</p> <p>In the header for whatever controller you're detecting shakes in add a boolean:</p> <pre> BOOL isRotating; </pre> <p>In your implementation file add the two UIViewController methods we want to override -- something like:</p> <pre> - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration]; isRotating = YES; } - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { [super didRotateFromInterfaceOrientation:fromInterfaceOrientation]; isRotating = NO; } </pre> <p>Now, do something like this for your event handler:</p> <pre> - (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event { if (event.subtype == UIEventSubtypeMotionShake && !isRotating) { [self.navigationController popViewControllerAnimated:YES]; } } </pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload