popToViewController presenting a black view - uiviewcontroller

I have an app that has many different views. The entry point to the app is the home page where I have 2 buttons (note that the home page is embedded in a navigation controller). Each button leads to a new stack of views, I tried embedding the first view of those stacks into a navigation controller, but when I push a button on the home page that leads to a new stack, the app crashes giving me a "Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing a navigation controller is not supported'" message. So I avoided embedding the stacks into a nav controller. The problem happens when I push the save button in the last view of the stack. In there I did the usual
self.navigationController?.popToViewController(firstViewController, animated: true)
This does not work and I get sent to the firstViewController, however the navigation bar buttons don't show up, the background is black and nothing shows. If I popToRootViewController however, it works. Cheers!

Alright well I feel stupid now, I realized that the segues between my buttons and view controllers were push segues. Now I embedded the first view controller of both stacks in a navigation controller, and changed my segues into modal segues. By doing that I was able to use popToRootViewController instead of popToView Controller... Now my save button leads back to the view controller I wanted to show, everything works fine.

Related

Windows Phone Universal - Issue in Navigation and On Loading of page

I am facing a weird problem in windows phone 8.1 page navigation.
I have got two pages.
Login page > Consists of app bar in which one of the button take us to second page.
Second page is Cached using MVVM i.e Registered the Second page to IOC on launch of app and binding the instance of it to page 2 XAML.
In the Second page View model Constructor I am making Server call to get the data.
Problems facing.
On Clicking the app bar button to navigate to second page, the app stays in the first page until the second page make server call and get the response. Then its navigating.
But actual behavior must be it should navigate to second page and wait there to get response showing progress bar.
One quick fix is I made the thread to stop for some 50 millisecond in page 2 constructor of view model and then made service call
It navigated to Second page immediately and waited there until response but the previous page App Bar still displays until I get the response.
I even find the quick solution for it by Collapsing the App bar just before Navigating to that page.
I know these quick fixes are not good. So please help me to find out the problem or if you already know please revert back with the solution.
Don't use constructor to initiate the web service calls . Use OnNavigatedTo or Page_Loaded event .

Catching back and home keys

After I set up my new project with libGDX v1.3.1 i am stuck with something that should be easy. In my main class which extends game I have:
Gdx.input.setCatchBackKey(true);
but I cannot get any response from this (in render method):
if(Gdx.input.isButtonPressed(Keys.BACK)){
this.dispose();
}
It like nothing was pressed, although I can see that the button was pressed in logCat console.
I need to mention that I was using the exact same code until libGDX version 1.0.0 (or the first one with gradle).
Note: i have also tried implementing InputProcessor and then setting the input processor. Result was the same.
And for the home button: using Gdx.input.setCatchMenuKey(true); is not working.
Use isKeyPressed instead of isButtonPressed. Buttons only refers to the three mouse buttons on a desktop game. Everything on Android is a Key (or Peripheral).
You mentioned "home button" but the code you posted is for the menu button. There is no way to catch the home button unless you make your manifest declare your app as a launcher replacement, in which case, the home button will always open your app, even when it's closed, and the user will have no easy way to get to the home screen. And libgdx doesn't have that functionality built in, since that would be weird. You would have to implement it yourself in your manifest and main Activity.
Also, disposing of this, whatever this is, sounds dangerous to do from the input handler. You could be about to render stuff and cause a crash. But I'm not sure where you're trying to use it from. Maybe it's OK.

Windows Phone Application Bar Instance Remaining Same When Back Key Pressed

I Have Created an application bar in the First Page and when a click occurs, it navigates to the Second Page and creates a new Application Bar in CodeBehind c#.
Till here it is Working fine but when i press the Back Hard Button while on the second page, the application bar instance is still remaining and appearing in first page.
In the ONNAVIGATEDTO method i'm making the instance of the first page appbar as null but it is not working and the previous application bar (of the Second Page) is still showing in the firstPage.
The application bar is different for each page. No need to create it in code behind.
The null assignment does not work because the appbar is not rendered yet. If you insist of doing it in code behind, which is not recommended, do it on page load. There is also an Items.Clear() method you can use to remove the app bar items. You should do it in XAML though.

Tabbrcontroller issue in iphone

I have implemented tab bar controller with four navigation controllers
each one has its on root view controller.
Below is my scenario-
While I am selecting a tab from tab bar controller the appropriate
root view controller has been launched.
From that root view controller I am pushing another view controller.
2.Now I am selecting a different tab and load its respective root view controller through its navigation controller.
Now again I am selecting a tab from tab bar was selected previously as
describe in point 1 above. Now it is showing a view controller
which was pushed previously from its root view controller.
I am facing issue as described by step by step scenarios in below image -
I want to launch root view controller instead of a view controller which was being pushed from that root view controller. Is it possible?
if any answer regarding my question on stack over flow please provide that stack over flow link or if any suggestion please provide to me. Thanks in advanced.
You need to intercept the tab bar touch so that, as well as switching the selected tab, the controller calls [currentNavController popToRootViewControllerAnimated:NO];.
This can be done by the tab bar delegate tabBarController:didSelectViewController:, which should keep a record of the previously selected view controller so that it can pop it to root - but only after the new view controller is shown.

UIViewController navigation - Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted

In my app I use navigation controller to traverse between various viewcontrollers. I have view controllers A,B,C,D and E. I use push and pop to go back and forth. The issue is when the app is launched, I am able to traverse through the view controllers without any issues.
Before every push and pop I NSLog the view controller stack and it is as good as expected. But when I come to the root view controller again and start the navigation again, I am getting "nested push animation can result in corrupted navigation bar"
Even before the error when I NSLog the stack, the stack has no issues and is as expected. Then I get the error "Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted."
What is surprising is I am not able to debug because I am clueless where the error is coming from as NSLog of viewcontroller stack is fine. Kindly help me.
This article help me - http://keighl.com/post/ios7-interactive-pop-gesture-custom-back-button/
I just override UINavigationController.