Mvvm交叉检测请求关闭或按下后退按钮 [英] MvvmCross detecting RequestClose or back button pressed

查看:69
本文介绍了Mvvm交叉检测请求关闭或按下后退按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现此主题表明MvvmCross无法检测到RequestClose或无法使用按后退按钮:解决方案

之前的建议仍然正确.

似乎可以很简单地将其内置到Android,WP7和iOS

我可能是错了或缺少了一些东西,但是当我过去尝试构建它时,简单性似乎很快变得复杂了:(


虽然在一个特定情况下看起来很简单,但对于一般框架而言,还有许多其他情况需要考虑-例如使用枢轴,选项卡,弹出窗口,模式,拆分视图等时-在这些多种情况下,标准方法可能并不完全通用.

尤其是iOS,有时会使这种检测变得更加困难(特别是在通常情况下,UIViewController可能会或可能不在NavigationController内).

更简单的方法是检测并发信号通知视图是否可见-但即使这似乎并不完全简单-在iOS中有些情况下ViewDidDisappear不会被调用-除此之外,这些事件可能根本不是您的应用需要响应的内容...

虽然您感觉只需要一个轮子,但显而易见的事实是,没有一个通用轮子-轮子有许多不同的样式和尺寸.现在,我已经看到了很多MvvmCross应用程序……而且我还没有弄清楚标准应用程序的外观.显然,在一个应用程序中正确的设计和架构是什么,看起来与在其他应用程序中采用的方法完全不同.


总的来说,我怀疑单个应用程序需要这种功能的情况会出现在定义明确的场景中,例如在已知的表示框架中具有已知的视图类型.在那种情况下,那么我怀疑对于当时的应用程序开发人员而言,仅针对该应用程序方案实施某些事情会非常简单.我还怀疑其中某些方案可以在某些应用程序之间共享-但我不确定一个代码模式是否适合所有应用程序-甚至很多.

我非常高兴看到用户在撰写博客时在其博客,github-post或论坛上谈论他们在该领域的经历.博客帖子,例如 http://www. gregshackles.com/2012/11/returning-results-from-view-models-in-mvvmcross/显示了如何在Mvvm之上应用和重用模式.

甚至有可能在此类博客文章中我们找到了在核心mvvmcross(及其他)库中获取更多功能的方法-但对我来说,保持核心库的轻便性,灵活性和可扩展性也很重要可能.

当人们像您自己一样谈论他们的跨平台mvvm体验时,我会尽力使链接页面保持最新状态-WP7 MVVMCross Detect RequestClose or BackKeyPressed inside ViewModels backkeypressed-inside-viewmodels

Did anything change since May, 2012? Any reasons why this functionality isn't build into MvvmCross? I don't want to re-engineer the wheel it seems like this can be built very simply into Android, WP7, and iOS. If I don't find solution, I will end up building it.

解决方案

The advice from before is still correct.

it seems like this can be built very simply into Android, WP7, and iOS

I may be wrong or missing something, but when in the past I've tried to build this, the simplicity seems to have become complicated quite quickly :(


While it may seem simple in one particular case, for a general framework there are numerous other cases to consider - e.g. when using pivots, tabs, popups, modals, split-views, etc - and in these multiple cases a standard approach may not be entirely universal.

iOS, in particular, sometimes makes this kind of detection much harder (especially in a general case where your UIViewController may or may not be inside a NavigationController).

What can be simpler is detecting and signalling the events for whether or not a view is visible - but even that doesn't seem to be entirely simple - there are cases in iOS where ViewDidDisappear will not get called - and besides, these events may simply not be what your app needs to respond to...

While it may feel like all you need is a wheel, the obvious fact is that there is no one universal wheel - wheels come in many different styles and sizes. I've now seen quite a lot of MvvmCross apps... and I've yet to work out what a standard app looks like. What's 'obviously' the right design and architecture in one app, can look totally different to the approach taken in others.


In general, I suspect that where individual apps need this kind of functionality then this will be in very well defined scenarios - e.g. with known view types inside a known presentation framework. In those cases, then I suspect implementing something just for that app scenario will be quite straight-forward for the app developer at the time. I also suspect that some of those scenarios can be shared between some apps - but I'm not sure that one code pattern will fit all - or even many.

I'm very, very happy to see users blog, github-post, or forum-talk about their experiences in this area when they write them. Blog posts like http://www.gregshackles.com/2012/11/returning-results-from-view-models-in-mvvmcross/ show how patterns can be applied and reused on top of Mvvm.

It may even be that out of such blog posts we find a way of getting more functionality inside the core mvvmcross (and other) libraries - but it's also important to me that we keep the core library as light, flexible and extensible as possible.

As people, like yourself, talk about their cross-platform mvvm experiences, I do my best to keep the links page up to date - http://slodge.blogspot.co.uk/p/mvvmcross-quicklist.html - that hopefully will help people share ideas, concepts and code.

这篇关于Mvvm交叉检测请求关闭或按下后退按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆