- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我的情况和this question很相似.我有一个通用的应用程序,其中 iPhone 为纵向,iPad 为横向,我使用 appDelegate.window.rootViewController = newScreen; 在所有主屏幕之间切换。 iPhone 应用程序完美运行。 iPad 应用程序有时会以纵向而不是横向显示屏幕。下面是一些示例转换代码:
AppDelegate* appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
ViewController* v = nil;
if (IS_IPAD()) {
v = [[ViewController alloc] initWithNibName:@"ViewController-iPad" bundle:nil];
}else{
v = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
}
[appDelegate.window setRootViewController:(UIViewController*)v];
我也从 this other question 尝试过这个:
AppDelegate* appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
ViewController* v = nil;
if (IS_IPAD()) {
v = [[ViewController alloc] initWithNibName:@"ViewController-iPad" bundle:nil];
}else{
v = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
}
[UIView
transitionWithView:appDelegate.window
duration:0.5
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^(void) {
BOOL oldState = [UIView areAnimationsEnabled];
[UIView setAnimationsEnabled:NO];
[appDelegate.window setRootViewController:(UIViewController*)v];
[UIView setAnimationsEnabled:oldState];
}
completion:nil];
但没有什么能解决它。
还尝试使用 [appDelegate.window makeKeyAndVisable] 和 [appDelegate.window makeKeyWindow],希望这会“冲击”它以做出正确的方向。
最佳答案
我知道了!
这是我的转换 block 的样子。我所做的关键事情是从 CALayer 复制变换(执行实际旋转的东西)。请注意,您必须包括 Quartz 框架和 #import <QuartzCore/QuartzCore.h>
在文件的顶部。
[UIView transitionWithView:self.window
duration:0.5
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{
BOOL oldState = [UIView areAnimationsEnabled];
[UIView setAnimationsEnabled:NO];
target.view.layer.transform = window.rootViewController.view.layer.transform;
window.rootViewController = target;
[UIView setAnimationsEnabled:oldState];
} completion:nil];
关于ios - rootViewController 已设置但显示方向不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11217123/
如果这个问题揭示了我知识中的大漏洞,我深表歉意。 我正在使用 setRootViewController 来切换 View ,因为我需要使用 SplitViewController。当我使用 setR
我有一个基本情况,当用户通过身份验证后,我删除当前屏幕(登录屏幕)并将其更改为应用程序内的另一个屏幕。 为此,我使用以下代码: if let appDelegate = UIApplication.s
我一直在做一个 Swift 项目,我有两个 View Controller ,登录 View Controller 和主页 View Controller 。当用户启动应用程序时,如果用户未登录,我想
我已经使用 SceneDelegate 在登录操作后更改 rootviewcontroller。它工作正常,但当我注销时,我无法再次执行导航。 这是我的 Scenekit 代码: let statu
我有一个应用程序,如果它在后台运行时间过长,我会在其中重新启动该应用程序。当用户在分配的时间后打开应用程序时,会发生重新初始化,并在获取所需数据时显示启动屏幕。当我从服务器获取数据时,我设置了 win
使用以下代码,我可以更改模态视图后面的rootViewController: let storyboard : UIStoryboard = UIStoryboard(name: "Main", bu
当应用程序被激活时,我正在创建一个文件。根据该文件的存在,加载不同的 View 。 我正在尝试的是 - (BOOL)application:(UIApplication *)application d
我正在开发一些自定义相机应用程序,我只想跳过我的登录页面并在用户已经注册时将我的相机主页设置为初始 Root View 。我是从 AppDelegate 或 View 代码内部执行此操作,但是我收到一
我是 iOS - Objective C 的新手,我正在尝试实现登录功能。我的 Storyboard 图如下所示: 因此,当有人单击帐户选项时,它会进入配置文件 View Controller ,并在
我的 iOS 应用程序在后台保持较长时间后会返回到 rootViewController。为了证明我有下面的图片 我一直导航到 ViewControllerC 并将应用程序保持在后台,当我返回应用程序
我有以下 Objective-C 代码来使用主屏幕快速操作启动我的应用程序: - (void)applyShortcutItem:(UIApplicationShortcutItem *)shortc
我正在构建一个在应用加载时执行大量设置的应用。因此,我有一个加载 View ,可以在设置发生时向用户显示一些信息... MyLoadingViewController *loadingViewCont
我想动态更改 rootViewController。这取决于 json 响应。我有一个 BOOL 值,它在收到 json 响应后发生变化。问题是即使条件为真,这个值也永远不会改变。 我的代码在下面,我
我想通过编码来制作导航 Controller 但是有一个问题:下面是我的代码 这是 Appdelegates.m #import "AppDelegate.h" #import "ViewContro
我的情况和this question很相似.我有一个通用的应用程序,其中 iPhone 为纵向,iPad 为横向,我使用 appDelegate.window.rootViewController =
我有一个 RegistrationViewController 和一个 LoginViewController: LoginViewController 是我的 InitialViewControll
有什么方法可以快速进入rootViewController?我想从堆栈中删除所有 View 并返回到 rootViewController,甚至不打扰它上面的 View 序列。 最佳答案 来自文档:
@IBAction func addButton(sender: AnyObject) { let alert = UIAlertController(title: "New Exercise
我想知道是否有人可以帮助我解决下面代码中的内存管理问题。我对 rootController 特别感兴趣,它是在我执行 initWithRootViewController 时被保留还是在窗口 addS
我的 iOS 应用打开时出现登录提示。一旦用户登录,它就会切换到主视图。 在 application:didFinishLaunchingWithOptions 中,我将 RootViewContro
我是一名优秀的程序员,十分优秀!