- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 Storyboard 应用程序, Root View Controller 是 UITableViewController
。
有时,当我启动应用程序时,我需要呈现一个 View Controller (不需要 Nib 或任何东西)。这就是我尝试这样做的方式:
在我的 UIApplicationDelegate
application:application didFinishLaunchingWithOptions:
:
SplashViewController * splashViewController = [[SplashViewController alloc] init];
splashViewController.semaphore = semaphore;
[self.window.rootViewController presentViewController:splashViewController animated:NO completion:nil];
问题是,此时 UITabBarController
还不在 View 层次结构中,所以我收到此警告:
Warning: Attempt to present <SplashViewController: 0xa786a10> on <UITabBarController: 0xb35d830> whose view is not in the window hierarchy!
将此代码从 AppDelegate 移动到 UITableViewController
的第一个 View Controller 的 viewDidLoad
看起来不对,因为我需要创建一些属性在我的 AppDelegate 中只是为了让我的第一个 View Controller 构建该 View 。这种逻辑不适合那里。
呈现此 View Controller 的正确方法是什么?
最佳答案
在您可以在这里显示 View Controller 之前,窗口必须是关键的并且是可见的。您可以通过执行以下操作来完成此操作:
[self.window makeKeyAndVisible];
所以你的完整代码应该是这样的:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self.window makeKeyAndVisible];
SplashViewController * splashViewController = [[SplashViewController alloc] init];
splashViewController.semaphore = semaphore;
[self.window.rootViewController presentViewController:viewController animated:NO completion:nil];
return YES;
}
关于ios - 在 Storyboard 应用程序上,如何在应用程序期间从 AppDelegate 呈现 View Controller :didFinishLaunchingWithOptions:?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14074062/
所以我尝试使用此方法根据用户在设置包中选择的内容加载特定主题。当我插入 NSLog 时,它将加载默认的它们(现代主题),但它永远不会更改为粉红色主题。 每次启动应用程序时都会加载此方法,即使应用程序仍
iOS 4 用户正在使用我的应用程序并使其在后台运行,有新版本可用,并且用户从 App Store 下载该新版本。 下载并安装新版本后,我的应用程序是否会退出并重新启动,以便我可以确保 didFini
我在启用推送通知时遇到问题。 使用此代码,我尝试启用通知: - (BOOL)application:(UIApplication *)application didFinishLaunchingWit
我嵌入到一个环境 (Adobe AIR) 中,无法覆盖 didFinishLaunchingWithOptions。还有其他方法可以获得这些选项吗?它们是否存储在某个全局变量中?或者有人知道如何在 A
我在现有项目中面临一个奇怪的问题。 从早上开始,我就面临着来自火力基地的一次奇怪的崩溃。 它工作正常,没有任何问题,但从早上开始我就面临这个问题。 崩溃: *** Terminating app du
我附上了两个调用方法的线程,该方法应始终在主线程上运行: 这导致了崩溃,因为我正在尝试创建持久存储协调器。 最佳答案 堆栈具有误导性。崩溃与 didFinishLaunchingWithOptions
在 didFinishLaunchingWithOptions 中,您如何知道应用程序是从前台恢复还是新启动?我需要知道这个方法,因为有 2 个任务要运行,具体取决于 launchOptions 是什
我正在我的应用程序中实现推送通知,并且当应用程序打开时一切正常:收到通知时,我的方法 [self processRemoteNotification:pushNotification] 按预期触发。现
didFinishLaunchingWithOptions` 做了什么以及何时调用它? 此外,我正在寻找类似 Android 中的“事件生命周期”图表的图表。如果您知道,请分享。 最佳答案 应用委托(
我觉得我应该知道这一点,但我不知道,这总是让我感到困惑。 浏览示例代码和教程时,我有时会看到 AppDelegates 有一个 @property UIWindow* 窗口, 然后是 @synthes
我想知道如何在应用更新下载后再次调用 didFinishLaunchingWithOptions,因为我所有的函数调用都在那里。 我需要再次调用它 self.dataArray = [self rea
我已经从后台终止了该应用程序。终止应用程序后,我发送一个推送通知。我对将要调用的 AppDelegate 函数有两个疑问: 1。 didFinishLaunchingWithOptions 会被调用吗
当我发送推送通知并且我的应用程序处于打开状态或在后台并单击推送通知时,我的应用程序将重定向到 PushMessagesVc viewController (如预期的那样) 我使用如下代码: -(voi
在为 iOS 开发时,您应用的第一个入口点是 -[AppDelegate application:didFinishLaunchingWithOptions:]。此方法的返回类型是 BOOL。默认情况
我对显示本地通知有相当大的理解问题。据我在其他线程中阅读,首先使用应用程序创建并安排本地通知。 要显示该通知,必须使用委托(delegate) didFinishLaunchingWithOption
我正在将文件导出为 NSData 对象并将它们的文件类型与我的应用相关联。 然后我可以通过在设备上打开邮件来导入文件,然后单击该文件并使用它打开应用程序。 但是,这样做时我无法从 XCode 启动应用
我只是想在 didFinishLaunchingWithOptions 中显示带有动画的 View ,我的代码如下: - (BOOL)application:(UIApplication *)appl
我在 didFinishLaunchingWithOptions 中有这段代码: self.window = [[UIWindow alloc] initWithFrame:[[UIScreen ma
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launc
我在应用程序一开始就有以下内容:didFinishLaunchingWithOptions: - (BOOL)application:(UIApplication *)application didF
我是一名优秀的程序员,十分优秀!