Back button not appearing on navigationcontroller - ios

Above is my storyboard. As you can see, view a and view b are both on the same navigation controller. They are both show segues. The segue to View B is activated manually by a button on the subview on the view of the previous "Home" controller and that works perfectly and has a back button. Here's the code:
- (void)storyButtonPressed:(UIButton *)button {
[self performSegueWithIdentifier:#"showStory" sender:self];
}
The segue to view A is activated manually by an if statement to see if the user is registered:
if (currentUser.active != true) {
[self performSegueWithIdentifier:#"showSignUp" sender:self];
}
However view A will not show up with a back button even though I'm going about it just like view B. I even tried to add a button to the navbar and manually pop off the view but that button won't even show up! Here's my document outline:
How do I get my view A to have a back button or at least allow me to add one manually?
Thank you.

Are you sure you the segue to A is set to "Show" and not to "Show Detail"?
Also the cancel button in your navBar looks like it might be covering up your button. You might try pinning your cancel button to the right side of your navBar and then seeing if it shows up with a back button.

Related

Swift - Remove View Controller from Navigation System

The best way that I can describe it is through and image, so i drew it out HERE. So, what happens is that in my table view, I press a button to add/edit information. When i am done, I press "Finish" at the bottom, which performs a simple segue back to the table view.
The Problem: Once back in the table view, the "back" button will now take me to the edit info page(which I just left) rather than the VC that came before it.
Is there any way to remove the Add/Edit info VC so that when I press "+" and "Finish" The back button will ignore the Add/Edit page?
Thank you for your help.
EDIT: . As you can see, when you press a button on the Table VC (lefT) it will take you to the right VC. Then, when you press finish at the bottom, it will perform a segue(no code, just a control-drag segue). The problem is still that the text message VC's back button will now direct back to the right VC, rather than the one preceding it (left)
I suppose you have a UITableView inside a UINavigationController since you have a back button, so:
User Tap Edit button: Push EditViewController in your UINavigationController
User Tap Finish from EditViewController: Save data, pop manually EditViewController and call reloadData of your UITableView
You would have to embed your complete sequence of view controllers in the navigation controller. This would maintain a stack of all the views that you would segue to. It will also give you a bcak button to go back to previous view. Alternatively, you can call the method popViewController() on navigation controller object to programmatically go to previous view. I hope that helps.

Subview button disappears on back button

I was trying to implement an overlaying button over UITableView in my UIView.
That's what I did:
Created button in Storyboard
Ordered elements:
In my viewWillAppear added:
[self.navigationController.view addSubview:self.myBtn];
It seems enough to display it correctly, but when I perform segue forth the next view I still see this button. That's why I added this in segue:
if ([[segue identifier] isEqualToString:#"addEvent"]) {
[self.myBtn removeFromSuperview];
}
Now it disappears on the next screen, but if I tap back on it, this button won't appear on my previous view. What's wrong?
If you know other ways to implement floating foursquare-like button, I'm opened to it. The simple way described here isn't working: UITableView overlays the button.
Button is placed below the table view. All that you need is swap table view and button in storyboard.
[self.navigationController.view addSubview:self.myBtn];
A navigation controller's view is probably regenerated each time the navigation stack changes. That would cause the button that you added to the nav controller's view to disappear.
In general, you should avoid messing with another view controller's view hierarchy. If you want to add a button over your table, that's fine, but do it in the context of your own view controller's view hierarchy.

UINavigationController swipe to go back issue

I am creating NavigationController app which contains login and other pages. I am hiding navigation controller in login page and displaying in other pages. I have back/logout button on the left side of the second screen. when i try to drag from second screen (i am not full swipe to the login screen), navigation bar in second screen becomes hidden. It never appears again on other pages. I need to go back to login and push to second view to make navigation bar to show. When i click back/logout button instead of swipe, it works.
Any idea on solving this issue
In your viewcontroller that you want NavigationBar visible use this code
-(void) viewWillAppear: (BOOL) animated {
[super viewWillApper:animated];
[self.navigationController setNavigationBarHidden:NO];
}

Replace left navigation button with custom button, then back

I have a UITableView within an UINavigationController. On the right of the UINavigationBar I have an "Edit" button. When I tap this button, all the textfields in the table cells become activated so I can edit them. The right button changes to "Save".
I'd now like the left "back" button of the UINavigationController to be replaced by a "Cancel" button which when I tap doesn't bring me back to the previous UIViewController, but just cancels editing mode.
When I tap "Save" the "Cancel" button should be changed back to the usual UINavigationController back button. Is there any easy way to do this? I tried accessing [[self navigationItem] leftBarButtonItem]. This works for the right button, but not the left one.
Set the leftBarButtonItem to your Cancel button. At the appropriate time, set the leftBarButtonItem to nil to remove your Cancel button. This will automatically restore the original back button that was in place before you added the Cancel button.
It sounds like the leftBarButtonItem is a "BackButton", which is set on the UIView(Controller) you used to navigate to the current View.
You can hide the BackButton following the answer in this question. This should be done, since you cannot change it's behavior.
I believe you are then able to use the leftBarButtonItem.
See this other SO question.
Then make sure you declare the cancel method similar to this.
(void)cancel:(id)sender {
[self.navigationController popViewControllerAnimated:YES];
}

iOS 6: How do I segue from inside a tableview embedded in a nav controller TO another VC?

I have an initial 'parent menu' view controller with a 'photos' button (more buttons to come like 'events').
From the Photos button I have a simple ctrl-drag segue to a navigation controller which has a tableview as it's first view(albums), collections view(thumbs), then imageview(fullsize).
The problem I am having is:
I want to be able to segue back to the initial simple 'parent menu' view controller from the first table view after the nav controller.
I tried:
dragging a button into the table view's top menu bar area (it was considered a UINavigationItem) and dragging a segue back to the menu... didn't work.
setup outlet from button in the tableview menu area to its parent view and calling [self performSegueWithIdentifier: #"BackToMenu" sender: self]; from there, didn't work.
dragging a button into the table view as a last item and ctrl+dragging it as a segue to the menu: didn't work.
tried a segue going back from the nav controller to the menu and manually calling it, but the outlet function connected to the 'menu' button I dragged into the tableview top back NEVER gets hit.
What am I missing?
I plan to have a few navigation controllers going out from the menu page in the storyboard from multiple buttons.
You don't need a segue for this. You can create a button in your table view and link it to an action in your table view which dismisses the currently presented view controller (I'm assuming your segue that presented the navigation controller stack in the first place was of a "modal" type):
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
Alternatively, you can look into "Unwind Segues" but I haven't used these myself yet so wouldn't like to include details here.
You can drag a "Bar Button Item" to the left side of the first table view after the navigation controller. From there, do the control-drag back from the bar button item to the initial view controller, and choose a "modal" segue. While this answers your question, as #jrturton said in the comments below, this isn't optimized, because it will create a new instance.
If you want to do this programmatically (which will return to the existing instance), create an IBAction for the Bar Button Item on the table view controller. For example in iOS 6:
-(IBAction)returnToParentMenu:(id)sender {
[self dismissViewControllerAnimated:YES completion:nil];
}
or in iOS 5:
-(IBAction)returnToParentMenu:(id)sender {
[self dismissModalViewControllerAnimated:YES];
}
What I wound up doing was making the nav controller first before anything and then my menu page was first with buttons down each respective path.
on the above: The ctrl+drag didnt work from the nav bar button, kept totally blowing up.
I did not realize I could go from nav controller to a regular view controller first. thought it needed to go to table view first since when you drag out a nav it comes paired with a table.
If I had 10+ 'points' in this strange forum I'd post a screen shot of the storyboard.
Thanks all

Resources