简体   繁体   English

在 Xamarin.iOS 启动屏幕上添加版本号

[英]Adding version number on Xamarin.iOS Splash screen

Anyone has an idea how can I update the label and put a version number on there so that I don't need it to write manually every time I publish the new version on iOS.任何人都知道如何更新标签并将版本号放在那里,这样我就不需要每次在 iOS 上发布新版本时都手动编写它。 Please download my sample project in this link Splashscreen with version number .请在此链接Splashscreen 中下载我的示例项目,版本号为

I try to add UIViewController to use it on Storyboard but it's not working.我尝试添加 UIViewController 以在 Storyboard 上使用它,但它不起作用。

first thing, it is not possible to provide dynamic value on the launch screen which comes as a default view with the IOS project.首先,无法在作为 IOS 项目默认视图的启动屏幕上提供动态值。 you have to create your own splashscreen by storyboard so you will have viewcontroller code behind and there you can do whatever the details you want to display.你必须通过故事板创建你自己的启动画面,这样你就会有视图控制器代码,你可以在那里做任何你想要显示的细节。 you can show the animation also there.你也可以在那里展示动画。

you have to set this splashviewcontroller as a rootviewcontroller in finishlaunching() of appdelegate.您必须在 appdelegate 的 finishlaunching() 中将此 splashviewcontroller 设置为 rootviewcontroller。

check below code:- try something like this.检查下面的代码:-尝试这样的事情。

public override UIWindow Window { get;公共覆盖 UIWindow 窗口 { 获取; set;放; } public RootViewController RootViewController { get; } 公共 RootViewController RootViewController { 获取; set;放; } }

  public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions){
     this.Window = new UIWindow(UIScreen.MainScreen.Bounds);
     UINavigationController navigationController = new 
     UINavigationController(new SplashViewController());
     Window.RootViewController = navigationController;

} }

I cannot download your code for security reasons on my network, but In Xamarin.iOS, You can get the version number from the info.plist then set your label text to the value.出于安全原因,我无法在我的网络上下载您的代码,但在 Xamarin.iOS 中,您可以从 info.plist 获取版本号,然后将标签文本设置为该值。 This way as you update the version for releases the label will automatically reflect the current version number.这样,当您更新版本的版本时,标签将自动反映当前版本号。

var appVersion = NSBundle.MainBundle.InfoDictionary["CFBundleVersion"].ToString();

lblAppVersion.Text = appVersion;

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

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