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.
Related
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 .
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.
I want to set up my view controllers like the Find My Friends iPad app. Based on what I've found so far, I believe that I need to:
Use a container view controller
Make the tab bar controller the root view controller of the container view controller
Add other view controllers, such as split view controller, as child view controllers to tab bar controller
Add some sort of callback methods to forward messages from the parent to the child view controllers (for rotation and appearance)
Can someone please confirm that I am on the right track? Also, if you can point to or add some sample code to help me get started, I will appreciate it.
Thank you.
You are correct. All 4 tabs on the "Find my Friends" iPad app are split views. It is actually very simple to get started with an app like that. I'm not sure what direction you are planning to take as far as content, but at least for the layout. Start a new project in Xcode and then choose master-detail application. It will automatically setup a split view with the left side as a table view and the rightside as a detail view. it will also presetup some editing methods and what nots. If you will be using core data at all, i would also highly suggest starting that with the checkmark as well. Good luck with your app!
I'd like to override the animation of popToRootViewControllerAnimated: (currently: YES) when a user taps on the same tab bar item that is already selected.
When the tab bar item is first tapped, I check whether the user is signed-in in the viewWillAppear: method of the tab bar item root view controller and if not, immediately push the sign-in controller with animation disabled.
controller.navigationItem.hidesBackButton = YES;
[self.navigationController pushViewController:controller animated:NO];
[controller release];
When the user successfully signs-in, I pop back to the root controller, [animation is] no problem:
[self.navigationController popViewControllerAnimated:YES];
However, the default behavior when tapping the current tab bar item again appears to make the following calls:
-[UITabBarController _tabBarItemClicked:]
which calls
-[UINavigationController popToRootViewControllerAnimated:]
I can't tell if YES is passed into that last one, but assume so based on observation.
If the user doesn't sign-in but taps the tab bar item again, it looks like the same [sign-in] controller is getting pushed/popped with animation since the viewDidLoad of the root controller just pushes the sign-in controller again. I'd like the animation to be NO in this one case.
To add to my problems, there are other navigation stacks where the sign-in controller can be pushed and it is appropriate for taps on its tab bar item to pop to the root controller.
I have implemented UITabBarControllerDelegate protocol and tabBarController:shouldSelectViewController: in the sign-in controller to check if the tapped bar item root controller is the same and if that controller is the class of the controller I want to special case, but it seems inelegant. Not only that, but now the sign-in controller must know about the class of a controller that could push it onto the navigation stack. While I can keep using the protocol method, there must be a better way to do this.
Thanks for your input and ideas!
I think the best solution to this problem would be presenting a modal view controller when the tab bar button is selected, and then returning NO. From the delegate method.
I am new to Monotouch and I am not finding the right documentation to do this.
I created a new iPad Storyboard Single View application. I have my inital Navigation Controller, my initial View Controller, and then I added two more View Controllers (Pages?). I created a button on the first two pages. I held down control and dragged each button to the next View Controller and setup each Segue as a push. When I run my application, I can move from page 1 to page 3 and back, no problems.
Now the problem is when I start adding controls and trying to wire them up. On the initial View Controller, I can hold down Control and drag controls over to the code and after I give it a name, it automatically adds my outlets and actions.
But the new two View Controllers I cannot do this. I have searched every where and the StoryBoard documentation and examples are difficult to find. Any help would be appreciated. Thanks!
You need to create a UIViewController class for each of the new View Controllers in Xcode, if you right click on the folder for where you want to create the class, then click Add New.
You then need to then wire them up to your View Controllers in the storyboard (you will see a drop down which shows the name of the class for the view controller in the properties I think it's the fourth icon from the right, it will be UIViewController). Once you have done this, you will then be able to wire up the controls on it.
Once you've saved it, it will automatically create the C# classes in MonoDevelop when you switch back to MonoDevelop. Don't try and do the class in Mono first as it causes you all sorts of issues!
Hope that helps, if you want more information about storyboards, I've found that the objective c stuff is about as good as you can get for now as there isn't too much support for monotouch storyboarcs yet.
Davoc