- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我创建了一个自定义 segue,它在容器内呈现一个 View Controller ,这与 Apple 自己的模态视图 Controller 非常相似(我将其实现为 UIViewController 子类)。
我现在正在尝试创建自定义展开转场,但我无法调用方法 -segueForUnwindingToViewController: fromViewController: identifier:
。
我还在我的容器上实现了 -viewControllerForUnwindSegueAction: fromViewController: withSender:
这样我就可以指向正确的 View Controller (呈现此模态的那个)然后是应该询问的方法因为我的自定义 unwind segue 不会在任何地方被调用。
现在,我关闭此模式的唯一方法是在 -returned:
方法上执行此操作。
有没有人可以通过自定义展开转场成功做到这一点?
编辑:更多代码和上下文
我的展开 View Controller 是在 Storyboard 中配置的,而不是以编程方式配置的。
我的 Controller 中有这些与展开转场相关的代码:
PresenterViewController.m
我在这里使用自定义方法关闭我的自定义模态框 (-dismissModalViewControllerWithCompletionBlock:
)。
- (UIStoryboardSegue *)segueForUnwindingToViewController:(UIViewController *)toViewController
fromViewController:(UIViewController *)fromViewController
identifier:(NSString *)identifier {
return [[MyModalUnwindSegue alloc] initWithIdentifier:identifier
source:fromViewController
destination:toViewController];
}
-(IBAction)returned:(UIStoryboardSegue *)segue {
if ([segue.identifier isEqualToString:@"InfoUnwindSegue"]) {
[self dismissModalViewControllerWithCompletionBlock:^{}];
}
}
MyModalViewController.m
这里我只使用 -viewControllerForUnwindSegueAction: fromViewController: withSender:
指向我应该展开到的 View Controller 。
- (UIViewController *)viewControllerForUnwindSegueAction:(SEL)action
fromViewController:(UIViewController *)fromViewController
withSender:(id)sender {
return self.myPresentingViewController;
}
我期望的行为是调用 MyModalViewController 以指向应该处理展开的 View Controller ,然后该 View Controller 在 之前调用了他的
被调用。-segueForUnwindingToViewController: fromViewController: identifier:
方法>-returned:
现在 -segueForUnwindingToViewController: fromViewController: identifier:
永远不会被调用。
我还必须说我已经尝试过不同的配置。我把我的方法放在任何地方,以返回它永远不会被调用的展开转场。我读到过我可以将导航 Controller 子类化,然后它会被调用,但我不知道它如何适合我的解决方案。
编辑 2:附加信息
我检查过 MyModalViewController 有他的 -segueForUnwindingToViewController: fromViewController: identifier:
方法,当我想关闭它提供的常规模态视图 Controller 时调用。这可能是因为他是层次结构中最顶层的 UIViewController。
检查后,我将 UINavigationController 子类化并使用该子类来包含我的 PresenterViewController。我很惊讶地注意到他的 -segueForUnwindingToViewController: fromViewController: identifier:
方法也被调用了。
我相信只有充当容器的 View Controller 才会调用此方法。这对我来说意义不大,因为他们不是唯一呈现其他 View Controller 的人,他们的 child 也在这样做。
我不能在这个子类中创建逻辑来选择使用哪个 segue 类,因为这个类不知道他们的 child 做了什么。
Apple 论坛目前已关闭,因此现在无法获得他们的支持。如果有人有更多关于这是如何工作的信息,请帮忙!我想缺少这方面的文档是一个很好的指标,表明它仍然有多不稳定。
最佳答案
为了补充@Jeremy 的回答,我在我的 UINavigationController 子类中使用以下内容从模态 UIViewController 展开到包含在 UINavigationController 中的 UIViewController 以正常工作(即我期望的方式)。
// Pass to the top-most UIViewController on the stack.
- (UIStoryboardSegue *)segueForUnwindingToViewController:(UIViewController *)
toViewController fromViewController:(UIViewController *)
fromViewController identifier:(NSString *)identifier {
UIViewController *controller = self.topViewController;
return [controller segueForUnwindingToViewController:toViewController
fromViewController:fromViewController
identifier:identifier];
}
.. 然后像往常一样在 UINavigationController 内的实际 ViewController 中实现 segueForUnwindingToViewController。
关于ios - -segueForUnwindingToViewController : fromViewController: identifier: not being called,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17720995/
我有一个 UIViewController,它被设置为一个名为 MainPVC.swift 的 UIPageViewControllerDataSource。这是我 Storyboard上的入口点。在
Apple API 文档指出 segueForUnwindingToViewController() 已弃用,我应该使用 unwindForSegue() 来代替自定义转场。我找到了 this pos
我有一个显示 View Controller 的 Custom Segue,然后有一个相应的 Custom Unwind Segue。这段代码在 iOS 8 中运行良好,通过生成 UIStoryboa
我创建了一个自定义 segue,它在容器内呈现一个 View Controller ,这与 Apple 自己的模态视图 Controller 非常相似(我将其实现为 UIViewController
我正在构建一个应用程序,最近发现了由传统转场引起的巨大内存泄漏。因此我了解了 unwind segue。如果我简单地使用,一切都很好: @IBAction func prepareForUnw
我是一名优秀的程序员,十分优秀!