Swift 2 - How do I customise the navigation controller back button to a custom button? - xcode

I am currently working on a project and when I switch to a ViewController, the back button appears at the top left, how do I set the back button so that it is customised with a custom button of my choice? Ideally I do not want the back button appearing at the top but I want it associated with a separate button when reverting back to the previous ViewController.

To not show the back button at the top just hide it.
self.navigationItem.hidesBackButton = true
And then just implement popViewControllerAnimated in your custom button action.
self.navigationController?.popViewControllerAnimated(true)

Related

Back Button Pressed is not firing

I'm trying to implement a function that will be called when user press back button.
Working exactly how i expect in UWP, but the issue is with android.
In android I got two back button,
One at top Navigation (Let's call it navbackbutton ), and other we get at bottom, the three android button "background apps,Home and back button(android backbutton),
Android back button is firing onBackpressed override method but navbackbutton is not, it is just taking me to the previous page.
I dont understand why it is happening and how to fix it.
Page.OnBackButtonPressed is only triggered with the hardware back button on Android .
You can override OnOptionsItemSelected within MainActivity to hook the navigation back button event , refer to here .
Another way is that customize NavigationPage.TitleView(a layout with a back button and title label) to replace the default navigation bar and then you can get the back button event .

Back button is not showing on Navigationbar . Xamarin

When show screen, navigation is showing at the Top.But Back button is not showing.
When i use Navigation.PushAsync method then back button is showing.
I am using below code.
Navigation.PushModalAsync(new LoginSelection());
how can i show backbutton at left side of Modal screen.
When you call PushModalAsync(), you are creating an another Navigation Stack of Modals.Thus, your LoginSelection() page is not added to the Page Navigation Stack,but it is added on Modal Navigation Stack.
Thus,there are no pages in your modal stack and that's why back button is not appearing
Check the below link:-
https://forums.xamarin.com/discussion/69952/navigationpage-pushmodalasync-and-back-button`
Xamarin Forms Reverse PushModalAsync

Xamarin Forms - Change back button image

I can successfully hide the back button but can't change image of button.
To hide back button:
NavigationPage.SetHasBackButton(page, bool);
There is Icon attribute but we need to change back button image.
The only way to do this is to override the NavigationBar on each particular OS you have.
For Android you will need to look at the ToolBar and on iOS is the NavigationBar.
Refer :
https://blog.xamarin.com/android-tips-hello-toolbar-goodbye-action-bar/
https://developer.xamarin.com/recipes/ios/content_controls/navigation_controller/change_the_back_button/

Xamarin Forms: GetBackButton

I have Xamarin App, in the app I have a page which I hide the navigation bar for design purposes. But I still want to show back button. What I could do is that I could make a back icon and put it on the layout and call Navigation.PopAsync() on image tab. However is there a way to get the designated back button from the app?

How do I add an "add" button to a tab in a uitableviewcontroller within a uitabbarcontroller?

xcode 4.6
using Storyboards
When I drag a Bar Button Item to the navigation bar at the top of one of the UITableViewControllers that are children of the UITabBarController xcode creates a new navigation bar at the bottom of the page instead of adding the button where I dropped it. I would be ok with this, but when I run the app the bottom navigation bar never shows up, so my button is never displayed.
If you need to visualize the app, picture the following: Root controller displays a list of accounts. When an account is clicked a tab controller lists tabs for opportunities and contacts. I need the ability to add opportunities and contacts from the relevant tab
Any help is greatly appreciated.
EDIT
I am not sure if this is the correct solution or not. I have embedded the uitableviewcontrollers in navigation controllers, which appears to have fixed the problem.
Follow-up question - Is this the correct way to handle this situation?
Yes, that is the correct way to handle this situation.
You should embed the view controller inside a navigation controller by clicking the view controller in your storyboard and using the Xcode menu "Editor" > "Embed In" > "Navigation Controller".

Resources