标签: uimodalpresentationstyle

如何在iOS 8中呈现半透明(半切)视图控制器

在iOS 7中,此方法没有问题:

_rootViewController.modalPresentationStyle = UIModalPresentationCurrentContext;
[_rootViewController presentViewController:self animated:NO completion:nil];
Run Code Online (Sandbox Code Playgroud)

但是在iOS 8中它没有做任何事情.如何解决?这是iOS 8的Bug吗?

uimodalpresentationstyle presentviewcontroller ios8

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

Unwind Segue不会使用UIModalPresentationCustom解除View Controller

我(通过其设置呈现使用自定义过渡模态的视图控制器modelPresentationStyleUIModalPresentationCustom,提供了一个过渡代表,和UIViewControllerAnimatedTransitioning对象).

在提供的视图控制器中,我有一个unwind segue连接到一个按钮.塞古火灾很好; IBAction调用呈现视图控制器中的方法,并且在呈现的视图控制器中也是如此prepareForSegue.但是,呈现的视图控制器不会被解除,并且animationControllerForDismissedController:不会调用适当的转换委托方法().

但是,如果我将呈现的视图控制器设置modalPresentationStyleUIModalPresentationFullScreen(默认值),则视图控制器将被正确解除(但这会破坏我的自定义转换).

我完全不知道该做什么.我查看了Apple的文档,并没有注意到任何说在处理自定义转换时必须使用unwind segue做特殊事情的事情.

我知道我可以使用呈现视图控制器dismissViewControllerAnimated:completion:IBAction方法调用,但我宁愿使用它作为最后的手段,让它按照它应该的方式工作(或者至少知道它为什么不起作用:) ).

任何帮助将非常感激,

提前致谢

uiviewcontroller ios uimodalpresentationstyle unwind-segue

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

UIModalPresentationCurrentContext - 未调用旋转方法

我正在尝试使用UIModalPresentationCurrentContext在VC之上呈现VC,以便查看其背后的视图.以下代码有效:

UIViewController *transparentViewController = [[UIViewController alloc] init];
self.modalPresentationStyle = UIModalPresentationCurrentContext;
[self presentViewController:transparentViewController animated:NO completion:^{
}];
Run Code Online (Sandbox Code Playgroud)

但是,当我按下VC后旋转设备时,旋转看起来完全搞砸了.它不是干净地旋转,而是笨拙地拉伸视图以适应新的方向.

此外,当我继承透明ViewController时,我发现它的viewwillautorotate方法没有被调用!(即使它以混乱的动画方式旋转)

UIModalPresentationCurrentContext样式是不是要旋转?有没有办法解决?还有其他人遇到过这个问题吗?

rotation transparent uiviewcontroller uimodalpresentationstyle

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

iOS 8.3 modalPresentationStyle OverCurrentContext不继承状态栏外观和可见性

请考虑以下设置:

  • 您有一个简单的应用程序,其中包含一个UINavigationController子类和一个UIViewController子类.
  • UINavigationController重写preferredStatusBarStyle()方法并返回UIStatusBarStyle.LightContent
  • UIViewController重写prefersStatusBarHidden()方法并返回true

在iOS 8.0 - 8.2中,当另一个UINavigationController(具有不覆盖任何内容的另一个UIViewController)与modalPresentationStyleset设置一起呈现时UIModalPresentationStyle.OverCurrentContext,新呈现的控制器继承状态栏外观和可见性.

但在iOS 8.3中完全相同的情况 - 新呈现的控制器不会继承状态栏的外观和可见性

另一个例子是呈现一个实例UIImagePickerController- 关于状态栏外观完全相同的事情.

问题是:

  • 为什么在iOS 8.3中新呈现的控制器不会继承状态栏外观?
  • 有什么变化(我无法在iOS 8.2到8.3 API差异中找到任何有意义的参考)?
  • 有没有优雅的解决方案,而不是覆盖外观和可见性方法?

statusbar uimodalpresentationstyle ios8.3

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

不推荐使用'UIPopoverController':首先在iOS 9.0中弃用

我开发了一个显示错误的项目:

不推荐使用'UIPopoverController':首先在iOS 9.0中弃用 - 不推荐使用UIPopoverController.弹出窗口现在实现为UIViewController演示.使用UIModalPresentationPopover和UIPopoverPresentationController的模态表示样式.

我的编纂是:

ViewController.h:

#import <UIKit/UIKit.h>
#import <Photos/Photos.h>
#import <MobileCoreServices/MobileCoreServices.h>



@interface ViewController : UIViewController
 <UIImagePickerControllerDelegate, UINavigationControllerDelegate>

- (IBAction)touch:(id)sender;

@end

@interface SecondView : UIViewController
<UIImagePickerControllerDelegate, UINavigationControllerDelegate>



//video gallery
@property (strong,nonatomic) UIPopoverPresentationController *popOver;
@property (weak, nonatomic) IBOutlet UIView *studentView;
@property (strong, nonatomic) NSURL *videoURL;


@end
Run Code Online (Sandbox Code Playgroud)

ViewController.m:

- (void)openGallery {

UIImagePickerController *Picker=[[UIImagePickerController alloc] init];
Picker.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;
Picker.mediaTypes=[[NSArray alloc] initWithObjects:(NSString *)kUTTypeMovie,  nil];
Picker.delegate=self;

if( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)

{


    UIPopoverController *popController=[[UIPopoverController alloc] initWithContentViewController:Picker];
    [popController presentPopoverFromRect:CGRectMake(0, 600, 160, 300) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
    self.popOver=popController;
} …
Run Code Online (Sandbox Code Playgroud)

objective-c ios uimodalpresentationstyle ios9

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

当设备方向改变时,带有 Over Current Context 的 iOS 10 UIViewController 不会旋转

我已将演示文稿类型设置为情节提要中的“当前上下文”。

当调用 segue 时,新的 UIViewController 会正确显示。

但是,当设备方向更改时,新的 UIViewController 不会旋转,即使其父 UIViewController 也会旋转。

在 StackOverflow 上搜索,我没有看到任何现代(iOS 9 及更高版本)对此的引用,仅用于处理 iOS 6 / 7。

如果在代码中设置,则 UIModalPresentationStyle 将设置为 overCurrentContext。

rotation orientation uiviewcontroller ios uimodalpresentationstyle

5
推荐指数
0
解决办法
299
查看次数

modalPresentationStyle .overCurrentContext导致在呈现的视图控制器上按下远程按钮时出现问题

我在使用.overCurrentContext modalPresentationStyletvOS视图控制器时遇到问题:

let vc = UIStoryboard(name: "", bundle: Bundle.main).instantiateInitialViewController() //representative of actually presented VC
vc.modalPresentationStyle = .overCurrentContext
present(vc, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)

在呈现的视图控制器上,按下菜单按钮将停止返回到呈现视图控制器.将其设置为.overFullScreen和时也会发生这种情况.blurOverFullScreen.但是,在将其设置为.currentContext或时,我没有遇到此类问题.fullScreen.在使用某些特定UIModalPresentationStyle的东西时,是否有任何特殊需要使用?

uiviewcontroller uimodalpresentationstyle swift tvos

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

确保 popover 的presentingViewController 是原始演示者

我有一个容器视图控制器。其中一个子视图控制器需要呈现一个弹出框。问题是弹出框presentingViewController最终成为容器视图控制器,而不是呈现它的子视图控制器。

*我已经设置definesPresentationContext属性true的子视图控制器(和它的导航控制器),但如果出现的控制器是不会改变任何东西(这是唯一有用modalPresentationStyle.currentContextoverCurrentContext

UIViewController present(_:animated:completion:)讨论文档如何根据演示样式来自另一个控制器。所以我希望有一种方法可以覆盖或拦截该决定,以便在这种情况下我可以确保弹出窗口presentingViewController是最初呈现它的控制器。

我在容器视图控制器中有其他与适应受此问题阻碍的大小类更改相关的功能。

有没有办法确保弹出框presentingViewController是原始演示者?这可能与如何presentationController创建有关,但我不知道如何利用该过程。

下面是演示问题的代码。如果您希望重现该问题,请在 Xcode 中创建一个新的 iOS Single View App 项目。然后用ViewController.swift下面的代码替换提供的内容。在 iPad 模拟器上运行。将添加一个带有一个子视图控制器的容器视图控制器,并且将从子视图中显示一个弹出窗口。调试器控制台将显示一些输出。注意弹出窗口presentingViewController是容器而不是子窗口。

注意:虽然以下是在 Swift 中的,但 Objective-C 响应也很好。

import UIKit

class ViewController: UIViewController {
    var childViewController: UIViewController!

    override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
        super.viewWillTransition(to: size, with: coordinator)

        coordinator.animate(alongsideTransition: { (context) in
            self.childViewController.navigationController?.view.frame = CGRect(x: size.width / 2, y: 0, width: …
Run Code Online (Sandbox Code Playgroud)

uiviewcontroller ios uimodalpresentationstyle uicontainerview

5
推荐指数
0
解决办法
576
查看次数

如何找到键盘未覆盖的视图部分 (UIModalPresenationStyleFormSheet)?

我有一个视图控制器显示一个带有 UITextView 的视图,我想在键盘出现时调整视图的大小,以便键盘不会覆盖 UITextView。我几乎在所有情况下都能正常工作。据我所知,我仍然在 iPad 上看到一些奇怪的东西,只有当视图控制器出现在 ModalPresentationStyleFormSheet 中时,而且只有在 LandscapeRight 方向上。

我的视图控制器的 -keyboardWillShow 的相关部分:

// We'll store my frame above the keyboard in availableFrame
CGRect availableFrame = self.view.frame;

// Find the keyboard size
NSDictionary *userInfo = [notification userInfo];
NSValue keyboardFrameScreenValue = userInfo[UIKeyboardFrameBeginUserInfoKey];
CGRect keyboardFrameScreen =  [keyboardFrameScreenValue CGRectValue];
CGRect keyboardFrame = [self.view convertRect:keyboardFrameScreen fromView:nil];
CGSize keyboardSize = keyboardFrame.size;

// Figure out how much of my frame is covered by the keyboard
CGRect screenBounds = [self.view convertRect:[UIScreen mainScreen].bounds
                                    fromView:nil];
CGRect myBoundsScreen = [self.view …
Run Code Online (Sandbox Code Playgroud)

keyboard screen-rotation modalviewcontroller ios uimodalpresentationstyle

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

如何使用导航控制器 iOS 13 从模态呈现的 ViewController 将 ViewController 推送到全屏?

我有一种情况,我有三个视图控制器,假设 VC1、VC2 和 VC3,我在 VC1 上以模态方式呈现 VC2,并使用导航控制器,如

   let nav = UINavigationController(rootViewController: VC2)
   self.present(nav, animation:true)
Run Code Online (Sandbox Code Playgroud)

我想要将 VC3 从 VC2 推送到全屏,而不改变 iOS 13+ 中 VC2 的演示风格。目前是 overCurrentContext。

ios uimodalpresentationstyle swift ios13

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