- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
情况:
我有两个由导航 Controller (UINavigationController) 管理的 View Controller (UIViewController)。在加载时,第一个 View Controller (一种等待屏幕)启动第二个 View Controller 的加载,这需要一些时间。就像现在一样,第一个 View Controller 不会转换到第二个 View Controller ,直到所有数据都已加载——据我所知,这是 UIKit 中的正常行为。
问题:
我希望第一个 View Controller (等待屏幕)在等待第二个 View Controller 加载时至少显示 2 秒。问题是,有时第二个 View Controller 的加载在 2 秒之前完成,2 秒的等待被中断。
梦想:
我希望从第一个 View Controller 到第二个 View Controller 的过渡延迟到 2 秒过去。
A) Dream Scenario A:
如果被推送的第二个 View Controller 的加载在 2 秒延迟之前完成,我希望过渡(您实际看到的动画)是延迟到 2 秒延迟完成。
B) 梦想场景 B:
如果在加载完成之前经过 2 秒,过渡(您实际看到的动画)应该在加载完成后立即正常发生。
在 objective-c 或 cocoa 中是否有任何回调或通知可以让我这样做?
谢谢。
更新/澄清:(抱歉,我没说清楚)
乍一看,NSTimer 似乎是我的解决方案。好吧,不幸的是它不是。 我知道如何使用 NSTimer 在延迟后推送 View Controller (不是问题)。实际上,当第一个 View Controller 加载时,我会立即推送第二个 View Controller 。这个想法是,由于第二个 View Controller 的加载需要一段时间,我给用户一个漂亮的等待屏幕与第一个 View Controller 。
想要控制的原因:
可能存在被推送的第二个 View Controller 的加载很快完成的情况——在这种情况下,第一个 View Controller 可能只在几分之一秒内可见。这看起来不专业。因此,我不想这样,而是想在恒定的时间内显示等待屏幕以保持一致性,并提供一些有关该应用程序的简短有用信息。我的应用程序是一本书,等待屏幕更像是 Frontis 的作品——显示标题和作者。
最佳答案
以后要进行方法调用,我发现最方便的方法是使用performSelector:withObject:afterDelay:
performSelector:withObject:afterDelay: Invokes a method of the receiver on the current thread using the default mode after a delay.
- (void)performSelector:(SEL)aSelector withObject:(id)anArgument afterDelay:(NSTimeInterval)delay
Parameters aSelector A selector that identifies the method to invoke. The method should not have a significant return value and should take a single argument of type id, or no arguments. See “Selectors” for a description of the SEL type. anArgument The argument to pass to the method when it is invoked. Pass nil if the method does not take an argument. delay The minimum time before which the message is sent. Specifying a delay of 0 does not necessarily cause the selector to be performed immediately. The selector is still queued on the thread’s run loop and performed as soon as possible. Discussion This method sets up a timer to perform the aSelector message on the current thread’s run loop. The timer is configured to run in the default mode (NSDefaultRunLoopMode). When the timer fires, the thread attempts to dequeue the message from the run loop and perform the selector. It succeeds if the run loop is running and in the default mode; otherwise, the timer waits until the run loop is in the default mode.
关于iphone - 如何延迟 UIKit 中的 UINavigationController 转换?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5066189/
我有几个由导航 Controller 控制的 View Controller 。 例如,viewController A 和 viewController B 都可以将 viewController
目前我在单独的 Storyboard中有一个导航 Controller ,它使用退出按钮。这个退出按钮应该返回到 rootViewController(那是在 mainstoryboard 中)这是一
我目前正在将我的应用程序迁移到 iOS 7 上,并且在新的导航 Controller /栏管理上已经卡了好几个小时了。 之前,当我们有导航 Controller 时,我们有这样的代码片段: UINav
我环顾四周,终究找不到用滑动手势替换 backbarbuttonitem 的方法。我想向左滑动并让应用恢复到之前的 View Controller 。澄清一下,我正在使用 UINavigationCo
我环顾四周,终究找不到用滑动手势替换 backbarbuttonitem 的方法。我想向左滑动并让应用恢复到之前的 View Controller 。澄清一下,我正在使用 UINavigationCo
我使用 320*44 图像自定义 NavigationBar backgroundImage。因此状态栏为黑色。这就是我想要的。但是,当我呈现此 navigationController 时,如您所知
我正面临以下代码的崩溃。场景是 这是我的应用委托(delegate)方法,我在其中使用 UINavigationController 加载 RTC_HomeVC。 - (BOOL)applicatio
目前我有一个使用 uinavigationcontroller 但仅在 Root View 中隐藏导航栏的应用程序,我想在某些应用程序中将此应用程序用作外部库并将整个应用程序作为一个菜单项推送。 但是
我有两个 View Controller ,ViewControllerA 和 ViewControllerB,嵌入在 UINavigationController 中。 ViewController
iOS 7 采用了一种新手势,在屏幕上从左到右滑 Action 为 UINavigationController 中返回按钮的快捷方式。 我的应用似乎没有免费采用这种行为。我需要做什么才能使这个手势可
我已经在这上面花了几个小时,但无法让它工作。希望有人能帮助我。 我有一个 UIPageViewController,当我在应用程序启动时将它添加到我的默认 View 时,它可以完美地工作。这就是我所做
我想为我的 UIToolbar 使用我自己的背景。 要使用 UINavigationBar 做到这一点,我刚刚使用了这个类别并覆盖了 drawRect 方法: @implementation
我正在展示一个 UINavigationController模态地,从 iOS 应用程序扩展中: UINavigationController *nav = [[UINavigationControl
我读到在 iOS 应用程序中有这样的结构是不好的。但是,如果应用程序有很多 UINavigationController 和 UITabBarController 怎么办?但是一个UINavigati
我们在 UISplitViewController 应用程序中有我们需要的特定行为。我们有以下 3 个 View 的层次结构 FormOneViewController - 在 MasterView
我试图将一个简单的 UIToolbar 放在模态呈现的 UINavigationController 的底部。在这个示例中,它应该包含两个按钮“取消”和“某事”。 ... UINavigationCo
我有一个 UITabBarController,其中包含一些选项卡。其中一个选项卡具有 UINavigationController 和 UITableViewController 作为 Root V
我的应用程序的整个导航系统都是围绕导航 Controller 构建的。我所有的风险投资公司都被插入和推出。我有一个从左侧出来的菜单系统“抽屉”,它是我的自定义导航 Controller 的一部分。在菜
我有一个 UINavagationController (NC),它显示“Items”数组的多个 UIViewController (VC) View ,并且我有一个 UINavigationCont
在我的 UISplitViewController ,主 View 是UINavigationController包含 UITableViewController .有时,当用户选择表中的项目时,我不
我是一名优秀的程序员,十分优秀!