简体   繁体   English

UIViewController使用MVVM + Coordinators模式进行转换

[英]UIViewController transitions using MVVM+Coordinators pattern

I am creating my first app with mvvm+coordinator pattern and I faced some interesting architectural problems. 我正在使用mvvm + coordinator模式创建我的第一个应用程序,我遇到了一些有趣的架构问题。 How could you implement custom view controller transitions with this pattern? 你怎么能用这种模式实现自定义视图控制器转换? The basic app structure is the usual list of items (each with a foto) + details view for each item. 基本的应用程序结构是通常的项目列表(每个都有一个foto)+每个项目的详细信息视图。 The animated view controller transitions are quite fashionable right now, ie tapping on the foto in the list animates the foto to the final position on the details view. 动画视图控制器转换现在非常流行,即点击列表中的foto可以将foto动画到细节视图上的最终位置。 Now, to implement this the transition has to know both the original and the final rect of the image. 现在,为了实现这一点,过渡必须知道图像的原始和最终矩形。 But the transition otherwise implemented only on the ViewModel level by the Coordinator. 但是转换只能由协调器在ViewModel级别上实现。 How can such particularity like the coordinates of the image inserted into the ViewModel transition event? 如何将这种特殊性如插入到ViewModel转换事件中的图像坐标?

You are right, the coordinates are not allowed to appear in viewmodel, but they abstraction. 你是对的,坐标不允许出现在viewmodel中,但它们是抽象的。 So in viewmodel you can put your abstraction and in view a converter to resolve this abstraction. 所以在viewmodel中你可以把你的抽象和视图中的转换器来解决这个抽象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM