【问题标题】:Getting xib dismissed让xib被解雇
【发布时间】:2018-11-04 13:38:40
【问题描述】:

我有屏幕:当我关闭屏幕 2 时,第一个是 xib,第二个是控制器。两个屏幕都被关闭而不是第二个控制器。

在 iOS(Xcode) 中

【问题讨论】:

  • 请点击帮助并参观。代码图片不是很有帮助。请点击编辑并将您的代码粘贴到问题中,删除链接,并确保代码格式正确。

标签: objective-c swift xcode


【解决方案1】:

如果你想删除 xib,那么你只需要removeFromSuperview 这样只有 xib 会删除。还请分享你的代码,以便我们了解你做了什么。

[子视图 removeFromSuperview]

.. 如果你想删除 viewcontroller 作为子视图,你需要这样做

yourViewController.willMove(toParentViewController: nil)
yourViewController.view.removeFromSuperview()
yourViewController.removeFromParentViewController()

1)refer this link for more info2)Link2

【讨论】:

  • 哪一个我必须删除 1 或 2。
  • @sagarSaw 如果您只想从视图控制器中删除 XIB,请使用我的代码。我将适用于任何 IBAction
  • func addBottomSheetView(scrollable: Bool? = true) { self.addChildViewController(bottomSheetVC) self.view.addSubview(bottomSheetVC.view) bottomSheetVC.didMove(toParentViewController: self) let height = view.frame。 height let width = view.frame.width bottomSheetVC.view.frame = CGRect(x: 0, y: 0, width: width, height: height) //bottomSheetVC.HeaderLbl1.text="hello all 2" }
  • 我只想关闭 tableview 屏幕。
  • 但是当我关闭 tableview 屏幕时,它也被关闭了 xib。
【解决方案2】:

您应该使用两个视图进行动画处理。

        presentedView.transform = CGAffineTransformTranslate(presentedView.transform, 0, DEVICE_HEIGHT);
        [UIView animateWithDuration:0.6f delay:0 usingSpringWithDamping:1 initialSpringVelocity:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
            presentedView.transform = CGAffineTransformIdentity;
        } completion:^(BOOL finished) {
            appDelegate.window.rootViewController = appDelegate.welcomeViewctrl;
        }];

【讨论】:

    猜你喜欢
    • 2019-01-16
    • 1970-01-01
    • 2013-03-25
    • 2020-03-28
    • 2015-10-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多