gpt4 book ai didi

ios - 在解除父 View 时隐藏登录 uiViewController

转载 作者:行者123 更新时间:2023-11-29 12:08:48 25 4
gpt4 key购买 nike

这是在我的应用程序中调用特定操作的普通 LoginView

sourceViewVontroller

if ([password length] == 0) {

loginViewController *seatView = [mainStory instantiateViewControllerWithIdentifier:@"loggingView"];



[self presentViewController:login animated:YES completion:nil];

}

它会检查用户在调用此操作时是否尚未登录,因此会将他重定向到 loginViewController,然后

登录 View Controller

UIStoryboard *mainStory = [UIStoryboard storyboardWithName:@"Main" bundle:nil];

DestinationViewController *Dest = [mainStory instantiateViewControllerWithIdentifier:@"destView"];


[self presentViewController:Dest animated:YES completion:nil];

它转到需要登录的 destinationView,现在我的问题是如何返回(关闭不是 presentmodalView)到 sourceViewController,或者简单地说,如何在成功时从队列中删除 loginViewController 并直接关闭到源?

目标 View Controller

// Tried to use presentView .. but i dont need to reload sourceView, just dismiss to it !

//[self presentViewController:srcView animated:YES completion:NULL];

//This is what am doing ..

[self dismissViewControllerAnimated:NO completion:nil];

或者让我知道是否有其他专业的方式来执行此登录流程

最佳答案

我建议你另一种方式:

首先在 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

您将检查用户是否登录。如果登录,您将设置 rootViewdestinationViewController。如果没有设置 rootViewloginViewController

示例代码:

UIStoryboard *mainStory = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
if (logged) {

DestinationViewController *Dest = [mainStory instantiateViewControllerWithIdentifier:@"destView"];
self.window.rootViewController = Dest;
} else {
LoginViewController *seatView = [mainStory instantiateViewControllerWithIdentifier:@"loggingView"];
self.window.rootViewController = seatView;
}

注销时,你只需调用notificationdelegatewindowrootViewController 设置为loginViewController.

关于ios - 在解除父 View 时隐藏登录 uiViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34151425/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com