Two ViewModels for a single View at MvvmCross - mono

Is it possible to use two ViewModels for a single View at MvvmCross?
The reason is an existing Core library which already has navigation in place and a working app on top of it. Now I need to create another app and leverage the only View for two ViewModels (in core lib there is one view navigated to another using ShowViewModel and I just want to stay at the same view and change my datacontext).
Thank you for any suggestions.

Yes
you can continue to use ShowViewModel and change the way navigation happens by overriding the presenter - see Custom Presenters in the wiki
or you can use a different navigation mechanism entirely - there's nothing forcing you to use ShowViewModel

Related

Cocoa app design recommendation

I have a Mac app that needs to be based on multiple modules. That is, a single window with multiple views, and the default view with a menu. That menu should open one module on the default window and then if I select another module, the contents of the window should change with another view. Those views also have different states, so I made multiple views for each module.
In a nutshell, my app is a single AppDelegate.h/.m, a single xib file, with one NSWindow object and multiple NSView views. Those views have different states, so I load different other related NSViews.
To load a view, I use [window setContentView:viewNameView]; which I know that causes the old NSView to lose state, so I need to keep them all in memory for each module.
Is this the right approach?
Thank you!
You don't describe how and where you want the menu but a widely used method is to have a sourcelist on the left and the content on the right. You see this everywhere including Apples own apps.
If you create a sourcelist on the left of your window and place an NSBox on the right side.
Set up the sourcelist (NSOutlineView) to react to - outlineViewSelectionDidChange: which is an NSOutlineView delegate method.
Here you can check the identifier on the selected item in the menu and set the content view for the NSBox accordingly with - setContentView:
Here's a great introduction to using NSOutlineViews for anyone interested.
Edit: Depending on how many views you have it might be easier to have an NSTabView (in tabless mode) and just switch tabs in the - outlineViewSelectionDidChange: method. This is also widely used and the user won't see the difference.
You will want to look up NSWindowController for managing your window and xib, and NSViewController for managing views. The app delegate shouldn't do much (in fact you probably could remove the header file and merge it with .m).
Some references to look at:
https://www.mikeash.com/pyblog/friday-qa-2013-04-05-windows-and-window-controllers.html
https://developer.apple.com/library/mac/samplecode/ViewController/Introduction/Intro.html
Yes that will work. What you may end up needing as well, is a custom Navigation Controller. Unfortunately Cocoa doesn't have an NSNavigationController, so you'll have to write something on your own. But basically yeah what you'll do is swap out the contentView with the next view you want to display-- and keep a stack of views you've navigated to so you can support going back (or you could use a dictionary to add transition keys to create strongly linked transitions)
Here's an good example somebody posted in a previous thread-- if you just search for Cocoa Mac Navigation Controller you should find some helpful results :)
Mac OS X Cocoa multiview application navigation
Another thing that you may want to keep in mind, which came up for me, is if your views are of different sizes. If they are, and you are using auto-layout, you will need to update the constraints to resize the window appropriately as views are swapped out

Custom Segue VS Custom Transition

Today I tried to perform a custom segue for UINavigationController push/pop operations and I didn't find a solution.
I can obviously perform the push operation with a custom segue with no problem, but the pop operation (using the default back button) seems to be complicated (Some notes here https://developer.apple.com/library/ios/technotes/tn2298/_index.html).
On the other side with iOS 7 performing custom transitions is quite simple and I can achieve a custom push/pop operations thanks to new APIs.
I which case you choose to create custom transitions and when you just work with custom segue?
My question is probably quite generic and it depends on what we need to do... But I'd like to have your opinion.
You can't perform a pop navigation with segues, A segues is only forward or one Directional, it can go reverse from its tack trace, you would have to manually pop your controllers using a back button, also I would go for Segues if I have a simple navigational app like the one's where you go from one controller to next , but choose Custom Transitions, when the navigation depends upon the data values or you need to perform a different action at a different input

how to use several controllers in Sencha Touch 2?

I'm looking for an example of a Sencha Touch 2 MVC application that has more than one model, view, controller. I want to see what is the recommended way of witching to a different subject in the application.
For example: Suppose I have an application to manage calls and messages. I will have some welcome screen with a welcome controller and no model, a recent calls model, view, controller, and a messages model, view, controller. My problem is with putting and removing everything I need in the main view port, without allocating elements that are not displayed.
All the examples I found use one controller to rule them all, and a viewport with cards. I was hoping for a better technique. Also from what I saw when I start the application they specify all the models and controllers of the application, but I did not see how it can be used or why it is a good design. I thought that we want to reduce allocations on the phone.
Any pointers to examples or guidelines for how to use several controllers will be greatly appreciated.
I guess you need to go for routing and destroying items then.
VIEW: Welcome -> okBtn press
CONTROLLER: Welcome -> onOkBtnPress -> call route START
Welcome -> deactivate -> destroy Welcome VIEW
START VIEW: view items
START CONTROLLER: route index -> Add new view to Viewport.
Without routing you need to add the new view in the Welcome view, which usually is not preferable.
So you basically call a route onBtnTap and destroy the old view onDeactiveView.

Loading different views into a custom view dynamically

I've an application that performs a multi-step process. Each step is implemented as a NSView subclass and I want to navigate between the different views. I'm trying this by implementing a custom view and then loading different views into the custom view I made. Is this the right way to do it?
What is the best approach to implement this?
until you use only one view your approach is correct. If you load a view into your custom view and remove it before loading another view ,i feel it's ok. make sure that you use only one view to accomplish your task which i feel is possible.
all the best.if you find a better approach plz update
TNQ

How to create two sections of the same screen using a custom view controller

I was wondering if someone could tell me how to create a custom view controller which will split the screen into two sections and manage the sections seperately in the same manner that the iPad Zillow app does this?
See http://www.zillow.com/ipad/ if you are unfamiliar with the app.
Thanks.
Use a UISplitViewController.
If you want a split view controller that works like the one in that app then you will have to write your own, UISplitViewController doesn't really have any settings that can be customized.