私は、ユーザーが認証されている場合にのみ使用できるアプリケーションを持っています。特に、私は2つの異なるUIViewControllerを作成しました。最初はLoginViewControllerと呼ばれ、2番目はHomeViewControllerと呼ばれます。 applicationDidFinishLaunching:
方法において、LoginViewControllerが作成され、このようrootViewController
プロパティに追加:私はログインを実行する方法を作成ログイン/ログアウトの移行を管理するための提案
LoginViewController* loginCtr = ... // alloc and initiWithNibName...
self.window.rootViewController = loginCTr;
[loginCtr release];
Whitin LoginViewController。ユーザーが認証されると、performLogin
というメソッドが実行されます。
- (void)performLogin
{
MyAppDelegate *appDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate switchView];
}
ここで、swicthView
メソッドは、アプリケーションデリゲートクラス内で実装されています。
- (void)switchView
{
if(VIEW_TYPE == kLogin) // Display Login
{
// create a new LoginViewController and assign it to rootViewController
}
else // Display Home
{
// create a new HomeViewController and assign it to rootViewController
}
}
は、ログイン/ログアウト移行を管理するために、よりエレガントなメカニズムを実装することが可能であるか、このタイプの実装では、貴重な解決策と考えることができるのでしょうか?
ありがとうございます。