gpt4 book ai didi

ios - 关闭一个 View 并从 applicationDidEnterBackground 中呈现一个新 View

转载 作者:搜寻专家 更新时间:2023-10-30 20:18:07 25 4
gpt4 key购买 nike

我有一个应用程序,当用户启动应用程序或从后台重新打开它时,它会显示自己的密码条目。当用户从后台打开它时,真实应用不应“闪现”,换句话说,安全屏幕需要在用户重新打开应用之前完全加载。

我的这个设置适用于大多数屏幕。

在一种情况下,用户可以将调用 segue 的应用程序从选项卡栏 Controller 旋转到水平 View Controller 。在那种情况下,我遇到了一些问题。如果我不弹出旋转屏幕,那么输入屏幕会水平显示,即使用户以纵向方式重新打开应用程序也是如此。

如果我确实用动画关闭它,那么锁定屏幕在应用程序重新启动之前不会开始加载,因此您会看到一闪而过的内容。

如果我在没有动画的情况下关闭它,那么锁定屏幕仍会水平显示。

这是从 applicationDidEnterBackground 调用的内容:

    TabBarController *tbc = (TabBarController*)self.window.rootViewController;        

void (^openPasscode)() = ^void() {
KVPasscodeViewController *passcodeController = [[KVPasscodeViewController alloc] init];
passcodeController.delegate = self;
UINavigationController *passcodeNavigationController = [[UINavigationController alloc] initWithRootViewController:passcodeController];

// Change animated to YES and the new view isn't loaded until after the app restarts
[self.window.rootViewController presentViewController:passcodeNavigationController animated:NO completion:nil];

};

if (tbc.isShowingLandscapeView) {
[self.window.rootViewController dismissViewControllerAnimated:NO completion:openPasscode];
} else {
openPasscode();
}

最佳答案

尝试子类化持有密码 View Controller 的 UINavigationController 并实现这些方法(来自 UIViewController.h):

- (BOOL)shouldAutorotate {
return YES; // when app launched while device in landscape. it needs to rotate to portrait.
}

- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (UIInterfaceOrientationPortrait == interfaceOrientation);
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationPortrait;
}

关于ios - 关闭一个 View 并从 applicationDidEnterBackground 中呈现一个新 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21828573/

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