Add Nav buttons on left hand side of Navigation bar - xamarin.ios

I have a Xamarin page with a Navigation bar at the top.
I keep changing the views on the page with some button clicks, but the page remains the same.
What I need is, when I load a new view (say View A) on this page, I want to add a Back button on the top Nav bar of the page.
I saw some forums where they are using Custom page renderers to add Back button.
But here, the page remains the same. Only the view changes. So, I guess I need to use the custom view renderer to add the Navigation button.
How can I achieve this, as NavigationController which I need to add a Nav button is present in Page renderers, not View renderers.
I need some help.
Thanks

UIBarButtonItem customButton = new UIBarButtonItem(
UIImage.FromFile("Image/image.png"),
UIBarButtonItemStyle.Plain,
(sender, e) =>{
//InitView
});
NavigationItem.LeftBarButtonItem = customButton;
this.NavigationItem.LeftBarButtonItem.TintColor = UIColor.Orange;

Related

Is it possible to attach event on the *opening* of the context menu?

I am developing a WebExtension and as you know it is impossible to inject content script on chrome://* pages and https://chrome.google.com/webstore/*. I have a buttons in a context menu and for correct UX I would like to drop my item from context menu on such protected page.
According to the documentation I can handle click on my context menu item, but looks like no way to check the url of the page on the moment of right mouse click without trying to inject content script into every page?
As a workaround I have a code that checks url after click to the menu item.

How to serve different page request from same button dynamically?

I have a fix top navigation bar like this. And I have several links to pages(e.g. foods.xhtml, cars.xhtml, planes.xhtml) in side bar navigation(Like: "similar questions" side bar in stackoverflow, so its like inverted 'L').
Goal: Click on any sidebar link(from home page) and it should take me to the next page(let's say "foods.xhtml", which has list of foods) and when I click on any food it will take me to next page(let's say Sandwich.xhtml) and a back button to be created on fixed top navigation bar to navigate back tolist of foods(foods.xhtml).
Questions:
When I click on one sidebar link(->foods.xhtml), how can I store the
foods.xhtml in backing bean so that when I go to sandwich.xhtml and
want to navigate back, the "back" button on fixed navigation bar
will point to foods.xhtml?
Note:
I want this to work for cars, planes. So the "back" button in top fixed navigation bar has different "page redirection" at different page served.

How to add an view on top on activity layout dynamically which automatically shifted the old view down

I am working on an App in which I have an icon on Action Bar.When I click on this Action Bar icon then an EditText should come on the top of layout(below Action Bar) and all of the other data on layout should shif down.I am using Relative Layout.
I know how we can dynamically add view in relative layout.But here I have to add item on top on layout, while there is also some view on top before clicking the icon.
Try the below if it works for you, this is what you'll need as per my understanding of your question.
EditText et = new EditText(this);
empty.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
et.setText("Dynamic EditText!");
et.setMinLines(1);
et.setMaxLines(3);
relativelayout.addView(et);
// assuming you already have your relative layout and the rest declared.

Why no back button on DateElement picker?

This walkthrough for MT.D shows a back button on the UIDatePicker that appears when a DateElement is tapped. I'm in an iPad app, and using an MT.D DialogViewController as a subview in an overall UIView. When the date picker slides up I just get the black background with no way to dismiss the picker (no nav bar w/ back button). Same problem exists for the radio group picker. Is this because the dialog view controller is being used as a subview? Any ideas how I might get a nav bar up with a back button using the built-in picker logic?
You must use the DialogViewController as a child element of a UINavigationController to get the back button. On iPad, you can embed the UINavigationController in a UIPopoverController.
Adding the view of a controller into the view of another controller is not considered good design on iOS and won't result in the behavior you expect.

BackButtonBarItem not working properly in iphone

I implemented the following code to show the navigation bar with a backbuttonbaritem.
[mapNavigationItem setTitle:#"Tracking"];
[mapNavigationItem setRightBarButtonItem:nil];
[mapNavigationItem setLeftBarButtonItem:nil];
UIBarButtonItem *stopTrackingBarButton = [[UIBarButtonItem alloc] initWithTitle:#"Stop Tracking" style:UIBarButtonItemStylePlain target:nil action:#selector(stopTracking)];
[mapNavigationItem setBackBarButtonItem:stopTrackingBarButton];
[mapNavigationBar pushNavigationItem:mapNavigationItem animated:NO];
[stopTrackingBarButton release];
The stopTracking button is displayed on the screen, but no title is displayed. When i click on the stopTracking button, it disappears and then shows the title.
Could someone please tell me whats happening??
Ok i think i wasnt clear enough,
I have a mapview with buttons in the tab bar, when the app starts the navigation bar shows 2 buttons, when i click on one of the Tab bar items, it should clear the navigation bar buttons and add a back button bar button item only. I am successful upto this stage.
But when i click on the BackBar button item, it disappears, and does not perform the action assigned to it.
FYI:
IBOutlet UINavigationBar *mapNavigationBar;
IBOutlet UINavigationItem *mapNavigationItem;
If you want to use a different title for your back button than the previous navigation title, then you need to change it just before pushing the new view controller and change it back again after popping it.
So something like:
self.navigationItem.title = #"Stop Tracking";
[self.navigationController pushViewController:mapNavigationItem animated:NO];
and in this class's viewWillAppear
self.navigationItem.title = #"Tracking";
Edit:
If you are not using the backbarbutton for taking the navigation controller back then dont set it as a backBarButton simply set it as left barButton item.
Plus it also seems like you are using same navigation bar for both tabs. not a good idea. Load both tab views from different viewcontrollers and add two different navigation bars to those views.

Resources