标签: uimodalpresentationstyle

UIModalPresentationPopover for iPhone 6 Plus在横向上不显示弹出窗口

我想总是ViewController在所有设备和所有方向上提供一个popover.我试图通过采用UIPopoverPresentationControllerDelegate和设置sourceView和来完成这个sourceRect.

这适用于所有设备和方向,除了横向的iPhone 6 Plus.在这种情况下,视图控制器在表单中从屏幕底部向上滑动.如何防止它始终出现在弹出框中?

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
let popoverPresentationController = segue.destinationViewController.popoverPresentationController
popoverPresentationController?.delegate = self
popoverPresentationController?.sourceView = self.titleLabel!.superview
popoverPresentationController?.sourceRect = self.titleLabel!.frame }

func adaptivePresentationStyleForPresentationController(controller: UIPresentationController) -> UIModalPresentationStyle {
return UIModalPresentationStyle.None }
Run Code Online (Sandbox Code Playgroud)

所有设备均在iOS 8.2或更高版本下

iphone ios uimodalpresentationstyle ios8 iphone-6-plus

32
推荐指数
2
解决办法
6482
查看次数

iOS 8键盘隐藏了我的textview

我有一个UIViewController使用self.accountViewController.modalPresentationStyle = UIModalPresentationFormSheet;,现在在iOS 8中,UITextView当它被推高时,最后一个是从键盘隐藏的.怎么避免呢?

cocoa-touch uikeyboard ios uimodalpresentationstyle

23
推荐指数
2
解决办法
9693
查看次数

ModalPresentationStyle的Popover不在iOS 7 iPad中居中

我有一个iOS 7的问题似乎是一个错误或我只是不做正确的事情.我有modalViewController,它在iPad上使用ModalPresentationStyle显示为popover.它不是标准尺寸,自定义尺寸.这是代码:

myViewController *myVC = [[myViewController alloc] init];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:myVC];
[nav setModalPresentationStyle:UIModalPresentationFormSheet];
[nav setModalTransitionStyle: UIModalTransitionStyleFlipHorizontal];
[self presentViewController:nav animated:YES completion:nil];
nav.view.superview.bounds = CGRectMake(0, 0, 320, 465);
Run Code Online (Sandbox Code Playgroud)

它在iOS 6中都运行良好,但在iOS 7中并没有集中.但是,如果我将ModalTransitionStyle设置为UIModalTransitionStyleCrossDissolve,它可以正常工作.但只有在这种模式下.也许有人偶然发现了这个,知道如何修复它?我不是解散效果的忠实粉丝.谢谢.

objective-c ipad modalviewcontroller uimodalpresentationstyle ios7

19
推荐指数
3
解决办法
2万
查看次数

UIModalPresentationStyle.CurrentContext Swift iOS 7

我想PresentedView在另一个视图中显示一个视图 - Background View使用iOS 7.在我的应用程序中,我正在使用UITabBArController,因此在运行时我不知道哪个视图将是背景视图(可能是任何标签栏项目).以下是结构:

UITabBarController
  ---> TabItem1 - FirstUIViewController
  ---> TabItem2 - SecondUIViewController
  ---> TabItem3 - ThirdUIViewController
Run Code Online (Sandbox Code Playgroud)

需要这样的东西:

在此输入图像描述

当应用程序加载时,我正在运行TabItem1 - FirstUIViewController.当我点击时TabItem3,我想要ThirdUIViewController出现在Top on上FirstUIViewController,'FirstUIViewController'应该出现在后台,没有启用用户交互.

到目前为止我做了什么:

  1. 因为,UIViewControllers被添加Relationship Controllers到出现TabBar Item在`的UITabBarController,我添加了一个SEGUE从tabbarcontroller到ThridViewController.

  2. 将此Segue的PresentationStyle更改为UIModalPresentationStyle.CurrentContext,并进行了以下修改

    func `viewDidLoad()` {
        super.viewDidLoad()
        self.performSegue("identifier", sender: self)
    }
    
    Run Code Online (Sandbox Code Playgroud)

什么都没发生,我只看到带有白色背景的'ThridViewController'

  1. 我试过手动编码的方法:

    func `viewDidLoad()` {
        super.viewDidLoad()
        let overlayController:UIThirdViewController = UIThirdViewController() //This controller has a view added on top of it, which covers top …
    Run Code Online (Sandbox Code Playgroud)

objective-c uiviewcontroller ios uimodalpresentationstyle swift

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

带有Transition的UIModalPresentationCurrentContext?

我试图模态呈现如下的视图控制器:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"addPopover"];
vc.view.backgroundColor = [UIColor clearColor];
self.modalPresentationStyle = UIModalPresentationCurrentContext;
[self presentModalViewController:vc animated:YES];
Run Code Online (Sandbox Code Playgroud)

现在使用UIModalPresentationCurrentContext手段我可以使用透明背景显示此视图,并查看新视图背后的另一个视图.然而,它阻止我能够通过转换呈现它.

有什么想法吗?或者我如何解决这个问题?谢谢.

iphone objective-c ipad uimodaltransitionstyle uimodalpresentationstyle

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

自定义呈现的UIViewController更改为全屏

我有一个使用UIModalPresentationCustom演示风格呈现的视图控制器.我使用自定义UIViewControllerTransitioningDelegate将视图控制器显示为侧边栏(因此它从屏幕边缘滑入并且不占据整个屏幕).

然而,当我然后使用UIModalPresentationFullScreen- 然后关闭全屏视图控制器呈现另一个视图控制器时,我的基础自定义显示控制器突然调整大小以占据整个屏幕.有谁知道为什么会这样?

编辑:这本质上是我animateTransition提供侧边栏的方法 - 我已经删除了大部分代码以使其可读.基本上它从transitionContext获取容器,添加目标视图控制器的视图并将其设置为容器动画.

- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext
{
    UIView *container = transitionContext.containerView;

    UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
    UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
    UIView *fromView = fromVC.view;
    UIView *toView = toVC.view;

    if( toVC.isBeingPresented )
    {
        [container addSubview:toView];

        //... Animate some new frame for toView            

        //Call [transitionContext completeTransition:YES] on animation completion
    }
    else
    {
        //... Animate fromView out

        //On completion remove fromView from superview

        //Call [transitionContext completeTransition:YES] on animation completion
    } …
Run Code Online (Sandbox Code Playgroud)

objective-c uiviewcontroller ios uimodalpresentationstyle presentviewcontroller

10
推荐指数
2
解决办法
3025
查看次数

将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
查看次数


如何在中心呈现自定义尺寸的模态视图控制器?

我想从底部呈现一个带有动画的自定义大小的模态视图控制器.我可以使用ModalPresentationStyleto 来实现这个动画FormSheet,但它强制我使用默认大小540x620并且我的视图不适合.

如何对位于屏幕中心的任意大小的视图(控制器)执行类似的转换?

uikit xamarin.ios ios uimodalpresentationstyle ios6

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

UIModalPresentationStyle.FormSheet始终在iPad上全屏(SWIFT)

我正在尝试将一些Objective-C代码翻译成SWIFT.

我正在加载一个UIViewController作为表单.这是objective-c中的代码:

generalPopup.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
generalPopup.modalPresentationStyle = UIModalPresentationFormSheet;
Run Code Online (Sandbox Code Playgroud)

这是Swift中的代码:

generalPopup.modalTransitionStyle = UIModalTransitionStyle.CoverVertical
generalPopup.modalPresentationStyle = UIModalPresentationStyle.FormSheet
Run Code Online (Sandbox Code Playgroud)

在Objective-C中,视图显示为FormSheet.在swift中,CoverVertical被维护,但视图占据整个屏幕而不是显示为FormSheet.

提醒一下,据Apple称,FormSheet是:

一种视图演示样式,其中所呈现视图的宽度和高度小于屏幕的宽度和高度,并且视图以屏幕为中心.如果设备处于横向方向且键盘可见,则向上调整视图的位置以使视图保持可见.所有未覆盖的区域都是灰色的,以防止用户与它们进行交互.

objective-c uiviewcontroller uimodalpresentationstyle presentviewcontroller swift

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