标签: uipresentationcontroller

用表单工作表演示加载的模态视图的自定义大小

我正在尝试使用表单表格在iPad中加载UIViewController.问题是这个新视图的大小,我将大小值放在IBuilder中,但模态视图采用固定值.

另外我试着在prepareForSegue中这样做:

HelpViewController *viewController = segue.destinationViewController;
viewController.view.superview.frame = CGRectMake(0, 0, 200, 200);
Run Code Online (Sandbox Code Playgroud)

但是不工作,有什么帮助吗?谢谢!

objective-c ipad ios uipresentationcontroller

40
推荐指数
5
解决办法
5万
查看次数

解除模态显示的视图控制器时帧不正确

我提出了一个UIViewController使用自定义转换和自定义UIPresentationController.视图控制器的视图不会覆盖整个屏幕,因此呈现视图控制器仍然可见.

接下来,我UIImagePickerController在此视图控制器的顶部提供一个实例.问题是,当我关闭图像选择器时,呈现视图控制器的框架覆盖整个屏幕而不是我想要它覆盖的部分.frameOfPresentedViewInContainerView在我的自定义中指定的框架UIPresentationController似乎完全被忽略.

仅当存在与所述图像拾取器modalPresentationStyleUIModalPresentationOverCurrentContext我的帧保持不变(因为没有视图从视图层次结构在第一位置去除这是有意义的).不幸的是,这不是我想要的.我希望图像选择器全屏显示,无论出于何种原因,它似乎搞乱了我的布局.我可能做错了什么或遗忘在这里?有什么建议?

objective-c uiviewcontroller ios presentviewcontroller uipresentationcontroller

18
推荐指数
2
解决办法
2379
查看次数

基于视图大小的自适应UIPresentationController

我正在转向UIPresentationController我的视图控制器的基础演示,但是与API有些混淆.

我有一个自定义侧边栏样式视图控制器演示文稿(类似于LookInsideWWDC 2014演示代码).

此类集群(UIPresentationController,UIViewControllerTransitioningDelegateUIViewControllerAnimatedTransitioning)在常规大小类视图中将视图控制器显示为屏幕边缘的侧边栏,并在紧凑大小的类视图上呈现与全屏相同的视图控制器.

在可调整大小的iPad目标上进行测试显示正确的行为:我将水平尺寸类设置为"紧凑",我的视图控制器从侧边栏切换到全屏.

但是,我想要更多粒度.当设备处于横向时,我想在iPhone 6和6+上使用侧边栏式视图控制器演示,并且纵向使用所有iPhone的全屏风格演示.

所以在我的方法中

- (void) viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
Run Code Online (Sandbox Code Playgroud)

我实现了一些逻辑来检测侧边栏是否会占用太多屏幕,假设我使用以下条件:

//If my sidebar is going to occupy more than half the new width of the view...
if( self.sidebarTransitionController.width > size.width / 2.0 )
{
    //Override the presentation controller's trait collection with Compact horizontal size class
    sidebarPresentationController.overrideTraitCollection = [UITraitCollection traitCollectionWithHorizontalSizeClass:UIUserInterfaceSizeClassCompact];
}
else
{
    //Otherwise override the trait collection with Regular
    sidebarPresentationController.overrideTraitCollection = [UITraitCollection traitCollectionWithHorizontalSizeClass:UIUserInterfaceSizeClassRegular];

}
Run Code Online (Sandbox Code Playgroud)

但这没有任何作用.UIPresentationController.overrideTraitCollection各州的文件: …

iphone ios8 adaptive-ui uipresentationcontroller uitraitcollection

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

演示后在UIPresentationController中调整呈现视图的帧

我正在使用自定义演示控制器来制作类似的东西UIAlertView.我希望它在键盘显示时向上移动.在UIKeyboardWillShowNotification处理程序中,我抓住新的键盘框架,将其存储在属性中,然后调用:

self.presentedView.frame = [wself frameOfPresentedViewInContainerView];
Run Code Online (Sandbox Code Playgroud)

在我的实现中-frameOfPresentedViewInContainerView,我考虑了当前的键盘高度.

这很有效,但self.presentedView直接修改框架感觉有点脏.我试图与不同排列的容器视图触发布局setNeedsLayoutlayoutIfNeeded,但没有引起呈现视图的不仅仅是直接设置它的框架移动等.

有没有更好的方法来做到这一点,而不仅仅是自己改变框架?

cocoa-touch uikit ios uipresentationcontroller

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

Swift - UITableView editActionsForRowAtIndexPath在单击"编辑"时打开UIPresentationController

嗨有什么办法可以在触发向左滑动时打开UIPresentationController并点击它Edit

    func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? {
        let delete = ....
        let edit = UITableViewRowAction(style: .Normal, title: "Edit") { action, index in
            //OPEN UIPresentationController HERE
        }
        return [delete, edit]
}
Run Code Online (Sandbox Code Playgroud)

edit uitableview ios swift uipresentationcontroller

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

当存在另一个控制器时,为什么UIPresentationController的高度会改变?

UIPresentationController用来显示底部提示。有时,presentationController可能会出现另一个控制器。并且,当关闭显示的控制器时,presentationController的高度也被更改。那么,为什么它改变了,我该如何解决这个问题。代码如下:

class ViewController: UIViewController {

    let presentVC = UIViewController()
    override func viewDidLoad() {
        super.viewDidLoad()
        DispatchQueue.main.asyncAfter(deadline: .now() + 1) { [weak self] in
            guard let `self` = self else { return }
            self.presentBottom(self.presentVC)
        }

        DispatchQueue.main.asyncAfter(deadline: .now() + 2) { [weak self] in
            guard let `self` = self else { return }
            let VC = UIViewController()
            VC.view.backgroundColor = .red
            self.presentVC.present(VC, animated: true, completion: {

                DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
                    VC.dismiss(animated: true, completion: nil)
                }

            })
        }
    }

} …
Run Code Online (Sandbox Code Playgroud)

ios swift uipresentationcontroller

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

为什么不用frameOfPresentedViewInContainerView定义我的视图控制器大小使它成为那么大?

我一直在关注在iOS 8中实现自定义视图控制器转换的教程UIPresentationController,到目前为止它都有意义,但我似乎无法让我的视图控制器成为合适的大小.

在该教程中,他们有以下代码:

class OverlayPresentationController: UIPresentationController {
   let dimmingView = UIView()

  override init(presentedViewController: UIViewController!, presentingViewController: UIViewController!) {
    super.init(presentedViewController: presentedViewController, presentingViewController: presentingViewController)
    dimmingView.backgroundColor = UIColor(white: 0.0, alpha: 0.5)
  }

  override func presentationTransitionWillBegin() {
    dimmingView.frame = containerView.bounds
    dimmingView.alpha = 0.0
    containerView.insertSubview(dimmingView, atIndex: 0)

    presentedViewController.transitionCoordinator()?.animateAlongsideTransition({
      context in
      self.dimmingView.alpha = 1.0
    }, completion: nil)
  }

  override func dismissalTransitionWillBegin() {
    presentedViewController.transitionCoordinator()?.animateAlongsideTransition({
      context in
      self.dimmingView.alpha = 0.0
    }, completion: {
      context in
      self.dimmingView.removeFromSuperview()
    })
  }

  override func frameOfPresentedViewInContainerView() -> CGRect {
    return containerView.bounds.rectByInsetting(dx: …
Run Code Online (Sandbox Code Playgroud)

uiviewcontroller uikit ios ios8 uipresentationcontroller

12
推荐指数
2
解决办法
2405
查看次数

使用自定义UIPresentationController子类呈现视图控制器时出现神秘崩溃

尝试UIViewController使用自定义UIPresentationController子类进行自定义显示时,我在iOS 8.1(设备和模拟器)上遇到崩溃.

引发的异常将以下内容打印到控制台:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSSetM addObject:]: object cannot be nil'
*** First throw call stack:
(
    0   CoreFoundation                      0x03bc9946 __exceptionPreprocess + 182
    1   libobjc.A.dylib                     0x03479a97 objc_exception_throw + 44
    2   CoreFoundation                      0x03ae018b -[__NSSetM addObject:] + 699
    3   UIKit                               0x023bf389 -[UIPeripheralHost(UIKitInternal) _beginPinningInputViewsOnBehalfOfResponder:] + 50
    4   UIKit                               0x01f81188 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 2306
    5   UIKit                               0x01fb47ab __40+[UIViewController _scheduleTransition:]_block_invoke + 18
    6   UIKit                               0x01e7a0ce ___afterCACommitHandler_block_invoke + 15
    7   UIKit                               0x01e7a079 _applyBlockToCFArrayCopiedToStack + …
Run Code Online (Sandbox Code Playgroud)

ios uipresentationcontroller

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

将definePresentationContext与UIModalPresentationStyle.custom一起使用

我使用视图控制器包含来管理一组子视图控制器,它们应该能够以自定义方式模态地呈现其他视图控制器.

我遇到了一个问题,当视图控制器使用时,不使用definesPresentationContext属性UIModalPresentationStyle.custom

作为一个例子,我有三个视图控制器:ROOT,A,和B

ROOT
 |_ A
Run Code Online (Sandbox Code Playgroud)

A是的孩子ROOT.我想提出B的模态A,同时使用自定义UIPresentationController,UIViewControllerTransitioningDelegateUIViewControllerAnimatedTransitioning.

所以,我的里面的代码如下的控制器A(注控制器AdefinesPresentationContext设置true):

func buttonPressed(_ sender: Any?) {
    let presentationController = MyCustomPresentation()

    let controllerToPresent = B()

    controllerToPresent.modalTransitionStyle = .custom
    controllerToPresent.transitioningDelegate = presentationController

    present(controllerToPresent, animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud)

但是,在我的演示控制器(也是我的UIViewControllerAnimatedTransitioning)内部,我遇到以下问题:

func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
    let fromVC = transitionContext.viewController(forKey: .from)
    let …
Run Code Online (Sandbox Code Playgroud)

uiviewcontroller ios uimodalpresentationstyle uipresentationcontroller

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

我可以让一个UIPresentationController在PresentingViewController上有userInteractionEnabled吗?

我正在为iPhone和iPad的通用应用程序构建自定义GUI.在iPad上,它主要依赖于"sideViews"等实用程序,如内容操作,detailInformation等(想想一个高级的SplitView).从视觉的角度来看,新的UIPresentationController让我能够呈现这些"sideViews"(并且不使用dimmedView),并且实现起来非常简单,可以构建和维护,同时仍然可以很好地与故事板集成.但是,当presentViewController可见时,我需要能够操作presentViewController的内容.所以我的问题是,我可以在呈现sideViews时在presentViewController上设置userInteractionEnabled(或类似)吗?

ios setuserinteractionenabled ios8 uipresentationcontroller

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