Chisx
Chisx

Reputation: 1986

This cancel button is not working, iOS7, Xcode 5.0 updated

I currently am working on my user creation page, here's a picture:

user creation page

I need the cancel button to simply "popViewControllerAnimated: YES" to my login page. The User Creation page is embedded in a navigation controller, and that NavController has it's own top bar set to "opaque black navigation controller" and the user creation controller does also("Top Bar" in att. inspector set to "opaque black nav controller"). The UIBarButtonItem has this outlet -->

@property (weak, nonatomic) IBOutlet UIBarButtonItem *cancelUserCreation;

and is connected to this IBAction .h:

- (IBAction)cancelUserCreation:(UIBarButtonItem *)sender;

.m:

- (IBAction)cancelUserCreation:(UIBarButtonItem *)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}

What am I doing wrong? Provide code if you can please.

P.S. The UserCreation page is embedded in a navigationController, consisting of three layers in the following hierarchy: MasterView>ScrollView>ContentView, where ContentView holds all of the objects in the view, and the segue from my login page to that navController is modal. altogether, the transitions are: LoginHomeViewController->modalseg->navController->embed->UserCreationViewController

Upvotes: 0

Views: 172

Answers (1)

Wubao Li
Wubao Li

Reputation: 1748

The UserCreationViewController is the root view controller of the navController, popViewControllerAnimated method does nothing. You cannot pop the last item on the stack.

call this:

[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];

Upvotes: 1

Related Questions