问题描述
我想向单点触控/xamarin 项目添加启动画面.
I want to add a splash screen to a monotouch/xamarin project.
初始屏幕应该执行一些逻辑,然后将用户导航到两个屏幕之一,登录屏幕/登录屏幕.
The splash screen should perform some logic and then navigate the user to one of two screens, logged in screen/Log in screen.
在单点触控中正确的做法是什么?(我是 monotouch 和 IOS 的新手).
What is the correct way to do it in monotouch? (I am new to monotouch and IOS).
推荐答案
我会怎么做,是这样的:
How i would do it, is something like this:
- 将启动画面设置为 rootviewcontroller,在后台执行逻辑,然后开始检查用户是否已登录.
- 然后在异步完成调用中,将用户导航到登录屏幕并将其设置为导航控制器中的新 rootviewcontroller.如果用户未登录,请在登录屏幕顶部推送一个 topviewcontroller - 在开始在登录屏幕中加载用户特定数据之前,请记住检查用户是否已登录.
示例:
MySplashController splash;
Navigationcontroller nav;
UIViewController masterviewcontroller;
Public override void FinishedLaunching(UIApplication app, NSDictionary options){
splash = new MySplashController();
window.rootviewcontroller = splash;
window.makekeyandvisible();
}
void MyAsyncLoggedInCall(bool loggedin){
if(loggedin)
LoggedIn();
else
LogOn();
}
void LoggedIn(){
masterviewcontroller = MyLoggedInScreen();
nav = new navigationcontroller(masterviewcontroller);
window.rootviewcontroller = nav;
}
void LogOn(){
masterviewcontroller = MyLoggedInScreen();
nav = new navigationcontroller(masterviewcontroller);
window.rootviewcontroller = nav;
nav.TopViewController.PresentModalViewController(new MyLogInScreen(),false);
}
这只是其中一种方法.您还可以查看如何实现 facebook 登录功能,并在您的应用程序中执行类似操作,因为它与您的问题非常相似.Monotouch 绑定
This is just one of the ways to do it. You can also look at how to implement the facebook login functions, and do something like that in your application, as its quite similar to your problem. Monotouch bindings
这篇关于Monotouch 从启动画面导航的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!