我想总是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或更高版本下
我有一个UIViewController使用self.accountViewController.modalPresentationStyle = UIModalPresentationFormSheet;,现在在iOS 8中,UITextView当它被推高时,最后一个是从键盘隐藏的.怎么避免呢?
我有一个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
我想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'应该出现在后台,没有启用用户交互.
到目前为止我做了什么:
因为,UIViewControllers被添加Relationship Controllers到出现TabBar Item在`的UITabBarController,我添加了一个SEGUE从tabbarcontroller到ThridViewController.
将此Segue的PresentationStyle更改为UIModalPresentationStyle.CurrentContext,并进行了以下修改
func `viewDidLoad()` {
super.viewDidLoad()
self.performSegue("identifier", sender: self)
}
Run Code Online (Sandbox Code Playgroud)什么都没发生,我只看到带有白色背景的'ThridViewController'
我试过手动编码的方法:
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
我试图模态呈现如下的视图控制器:
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
我有一个使用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
我使用视图控制器包含来管理一组子视图控制器,它们应该能够以自定义方式模态地呈现其他视图控制器.
我遇到了一个问题,当视图控制器使用时,不使用该definesPresentationContext属性UIModalPresentationStyle.custom
作为一个例子,我有三个视图控制器:ROOT,A,和B
ROOT
|_ A
Run Code Online (Sandbox Code Playgroud)
A是的孩子ROOT.我想提出B的模态A,同时使用自定义UIPresentationController,UIViewControllerTransitioningDelegate和UIViewControllerAnimatedTransitioning.
所以,我的里面的代码如下的控制器A(注控制器A已definesPresentationContext设置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
对于UIViewController,我们有UIModalTransitionStyle和UIModalPresentationStyle
问题是它们有什么区别?
uiviewcontroller uimodaltransitionstyle uimodalpresentationstyle
我想从底部呈现一个带有动画的自定义大小的模态视图控制器.我可以使用ModalPresentationStyleto 来实现这个动画FormSheet,但它强制我使用默认大小540x620并且我的视图不适合.
如何对位于屏幕中心的任意大小的视图(控制器)执行类似的转换?
我正在尝试将一些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
ios ×6
objective-c ×5
ipad ×2
iphone ×2
swift ×2
cocoa-touch ×1
ios6 ×1
ios7 ×1
ios8 ×1
uikeyboard ×1
uikit ×1
xamarin.ios ×1