相关疑难解决方法(0)

视图在被呈现后被UITransitionView阻止

我有一个侧面导航控制器,并通过UIButton呈现它.当我直接将这个NC作为根视图控制器时[self presentviewcontroller: NC animated: YES completion: nil],某些原因NC的菜单面被一个UITransitionView我无法消失的东西阻挡.

我附上了一张照片 查看层次结构. 这里 是另一个.

我尝试过以下方法:

UIWindow *window = [(AppDelegate *)[[UIApplication sharedApplication] delegate] window];
    window.backgroundColor = kmain;


    CATransition* transition = [CATransition animation];
    transition.duration = .5;
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    transition.type = kCATransitionPush;
    transition.subtype = kCATransitionFromTop;

    [nc.view.layer addAnimation:transition forKey:kCATransition];

    [UIView transitionWithView:window
                      duration:0.5
                       options:UIViewAnimationOptionTransitionNone
                    animations:^{ window.rootViewController = nc; }
                    completion:^(BOOL finished) {
                        for (UIView *subview in window.subviews) {
                            if ([subview isKindOfClass:NSClassFromString(@"UITransitionView")]) {
                                [subview removeFromSuperview];
                            }
                        }
                    }];
Run Code Online (Sandbox Code Playgroud)

但它非常hacky,并且随着窗口的rootviewcontroller在转换过程中发生变化,它会有点波动,导航控制器的一部分和右上角变黑.看起来很糟糕.

uiviewcontroller uinavigationcontroller catransition uiviewanimationtransition ios

16
推荐指数
3
解决办法
7764
查看次数

如何在半屏幕上呈现ViewController

我有一个从底部UIViewControllerUIView覆盖viewController的1/3.像这样

在此输入图像描述

我想在另一个ViewController上呈现这个viewController.它应该从底部动画出现,它应该忽略到底部动画.

但我不希望它覆盖整个屏幕.显示它的viewController应该在后面可见.

这似乎是一个基本问题但我无法完成它.有人可以指点我的方向吗?

编辑:

这就是我迄今为止所尝试过的.我创建了这些类

// MARK: -

class MyFadeInFadeOutTransitioning: NSObject, UIViewControllerTransitioningDelegate {
var backgroundColorAlpha: CGFloat = 0.5
var shoulDismiss = false

func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {

    let fadeInPresentAnimationController = MyFadeInPresentAnimationController()
        fadeInPresentAnimationController.backgroundColorAlpha = backgroundColorAlpha

    return fadeInPresentAnimationController
}

func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {

    let fadeOutDismissAnimationController = MyFadeOutDismissAnimationController()

    return fadeOutDismissAnimationController
}

}

// MARK: -

class MYFadeInPresentAnimationController: NSObject, UIViewControllerAnimatedTransitioning {

let kPresentationDuration = 0.5
var backgroundColorAlpha: CGFloat?

func transitionDuration(using …
Run Code Online (Sandbox Code Playgroud)

uiviewcontroller ios swift swift3

16
推荐指数
7
解决办法
2万
查看次数

Xcode 8 Swift 3:模式演示转换未调用的委托

问题

不调用'DrinkTransitioningDelegate'中的委托函数.'td'实例在演示文稿的生命周期内和之外保留在内存中.

class PresentingViewController: UIViewController {

    let td = DrinkTransitioningDelegate()

    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        let item = inventory.beverages[indexPath.row]
        item.isSelected = true
        let controller = DrinkViewController(item: item)
        controller.delegate = self
        controller.transitioningDelegate = td
        controller.modalPresentationStyle = .custom
        //let navCon = UINavigationController(rootViewController: controller)
        //navCon.transitioningDelegate = td
        //navCon.modalPresentationStyle = .custom
        present(controller, animated: true)
    }

}

class DrinkTransitioningDelegate: NSObject, UIViewControllerTransitioningDelegate {

    func presentationControllerForPresentedViewController(presented: UIViewController, presentingViewController presenting: UIViewController!, sourceViewController source: UIViewController) -> UIPresentationController? {
        return DrinkPresentationViewController(presentedViewController:presented, presenting: presenting)
    }

    let animationController = …
Run Code Online (Sandbox Code Playgroud)

animation ios swift

8
推荐指数
1
解决办法
7791
查看次数

如何创建一个只有屏幕一半高度的 ViewController?

我想要 pageSheet UIModalPresentationStyle segue 的所有功能,但我只希望呈现的 ViewController 显示一半屏幕(请参见下图中的示例)。

在此输入图像描述

我使用 pageSheet modalPresentationStyle 以模态方式呈现它,但它始终以 100% 高度呈现。

我一直无法弄清楚如何限制或修改 ViewController 的高度。我在 SecondViewController 中尝试了以下操作,但没有成功:

import UIKit

class SecondViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        self.preferredContentSize = CGSize(width: self.view.frame.width, height: 400)
    }
} 
Run Code Online (Sandbox Code Playgroud)

我正在使用 Storyboard Segues 和一个以模态方式呈现它的按钮来启动 Segue: 在此输入图像描述

ios swift

6
推荐指数
1
解决办法
8605
查看次数

Swift - iOS 9:如何在iOS 9中呈现自定义大小的UIViewController?

我有一个视图,我想显示一个自定义大小的UIViewController.但我没有成功.这是我的代码.

var vx = KeyboardViewController()
vx.modalPresentationStyle = UIModalPresentationStyle.FormSheet
vx.preferredContentSize = CGSizeMake(self.view.frame.width, 150)    
self.presentViewController(vx, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)

此UIViewController以全屏大小显示

ios presentviewcontroller swift

1
推荐指数
1
解决办法
3160
查看次数