【发布时间】:2014-07-11 17:59:51
【问题描述】:
我是 xamarin 和 MvvmCross 框架的新手。我目前正在为 android、windows phone 和 iOS 创建一个多平台应用程序。我目前在查找应用程序在哪个平台上运行时遇到问题。
我想要做的是在 app.cs 文件中有一个 if 语句。我想检查这是否是一个 iOS 应用程序然后做一些事情,否则做这个。但是我还没有找到任何好的方法来做到这一点,我什至不确定它是否可以在这个文件中完成
到目前为止,这是我的代码:
using Cirrious.CrossCore;
using Cirrious.CrossCore.IoC;
using Cirrious.MvvmCross.ViewModels;
using tax.Mobile.Core.Interfaces;
using tax.Mobile.Core.Logic;strong text
namespace tax.Mobile.Core
{
public partial class App : MvxApplication
{
public override void Initialize()
{
CreatableTypes()
.EndingWith("Service")
.AsInterfaces()
.RegisterAsLazySingleton();
#if (__iOS__)
RegisterAppStart<ViewModels.FirstViewModel>();
#else
RegisterAppStart<ViewModels.SearchViewModel>();
#endif
Mvx.RegisterType<IWebService, MockWebService>();
}
}
}
谢谢!
【问题讨论】:
-
符号的括号部分是否在项目属性中定义?通常你不会放它们。
-
您是否遇到任何错误?您提供的代码有什么问题?
-
听起来像是 IoC/DI 的工作,而不是 if/else 流控制。
-
等等,你想让应用根据平台以不同的视图开始?
标签: ios xamarin.ios xamarin mvvmcross