标签: uimodalpresentationstyle

iOS 7自定义推送过渡到透明视图控制器,保持视图控制器的视图在下方可见

我正在创建一个自定义推送转换(UINavigationController)从一个视图控制器到一个视图控制器,它的视图是透明的模糊.

我希望"from"视图控制器在新推的视图控制器下保持可见.

我知道如果以模态方式(使用modalPresentationStyle = UIModalPresentationCustom)呈现新的视图控制器,我可以实现这种效果,但有没有办法为导航控制器执行此操作?

我面临的问题是,在转换发生后,视图控制器的视图将从容器中删除.

objective-c uiviewcontroller uikit uinavigationcontroller uimodalpresentationstyle

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

iPad:UIModalPresentationFormSheet在横向模式下失败

我们的iPad版本存在下一个问题.

我在UITabBar中有一个NavigationController.我希望显示一个外观和感觉类似于电子邮件表单的表单.

我使用相同的代码来显示模型居中:

// View to be displayed in the modal
AdhocViewController *controller = [[AdhocViewController alloc] initWithNibName:@"AdhocViewController" bundle:[NSBundle mainBundle]];
controller.caller = self;

// The form will need a navigation bar to cancel or save the form
UINavigationController *modalViewNavController = [[UINavigationController alloc] 
                                               initWithRootViewController:controller];

// Configurate the modal presentation and transition
modalViewNavController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
modalViewNavController.modalPresentationStyle = UIModalPresentationFormSheet;

// Show the new view
[self presentModalViewController:modalViewNavController animated:YES];
Run Code Online (Sandbox Code Playgroud)

此代码在纵向模式下完美运行,但在横向上,视图部分显示在屏幕外...我还没有找到解决它的方法.

我测试了一些我在这里找到的解决方案......

并在预设模型视图后尝试添加下一行以调整其大小,但不能解决问题

controller.view.superview.frame = CGRectMake(0, 0, 600, 700);
controller.view.superview.center = self.view.center;
Run Code Online (Sandbox Code Playgroud)

有什么建议吗?

谢谢,

伊万

StackOverflow中的引用:

objective-c ipad modalviewcontroller uimodalpresentationstyle

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

UIModalPresentationFormSheet的四舍五入

原谅我,如果这是一个明显的问题,我相对较新.

我有一个模态视图,我设置了自定义大小和圆角:

- (void)viewWillLayoutSubviews{

    [super viewWillLayoutSubviews];
    self.view.superview.bounds = CGRectMake(0, 0, 600, 450);
    self.view.layer.cornerRadius  = 60.0;  
}
Run Code Online (Sandbox Code Playgroud)

然而,我发现当我绕视角时,我会在它的边缘出现这种灰色的颜色(好像它后面还有其他东西):(见图).

在此输入图像描述

如何删除这些灰色边缘,使其显示正常的背景内容?我试过添加

self.view.layer.masksToBounds = YES;
Run Code Online (Sandbox Code Playgroud)

然而,这仍然具有与上述相同的效果.

谢谢,

objective-c rounded-corners uiview ios uimodalpresentationstyle

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

currentContext 和 overCurrentContext 有什么区别?

文档两个currentContextoverCurrentContext具有相同的描述。

我可以发现的差异是:

  • 从何时可用:

    @available(iOS 3.2, *)
    case currentContext
    
    @available(iOS 8.0, *)
    case overCurrentContext
    
    Run Code Online (Sandbox Code Playgroud)
  • 随着currentContext,在关闭呈现的视图控制器后, viewWillAppear被覆盖的视图控制器被调用(它不必是提供上下文的视图控制器)。有了overCurrentContext它不会被调用。

还有其他区别吗?

uimodalpresentationstyle swift

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

与 ios 中的 .overFullScreen 演示样式相比,使用 .fullScreen 演示样式的好处

我很想知道如果我们使用.fullScreenvs.overFullScreen presentation style while presenting a view controller modally over rootViewController in an iOS app.

.overFullScreen如果presentedViewController有透明度,我阅读 using将不必要地显示它下面的内容,但如果我使用,.fullScreen那么在透明度后面也会有一个灰色的屏幕,看起来不太好。所以我不确定这有什么好处。

presentmodalviewcontroller ios uimodalpresentationstyle

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

使用UIModalPresentationOverFullScreen更改UIStatusbarStyle

我目前UIModalPresenationOverFullScreen用来呈现下一个控制器,此刻我想改变它UIStatusBarStyle.以前的控制器已经得到了UIStatusBarStyleDefault但我想要使用的电流UIStatusBarStyleLightContent.

因为UIModalPresenationOverFullScreen之前的控制器仍然在后台运行.这导致了当前将继承该样式的问题.

在plist文件中,我设置View controller-based status bar appearance为YES,并尝试了一些提示,例如:

[self setNeedsStatusBarAppearanceUpdate];
self.navigationController.navigationBar.barStyle =UIStatusBarStyleLightContent;
- (UIStatusBarStyle)preferredStatusBarStyle { 
      return UIStatusBarStyleLightContent; 
}
Run Code Online (Sandbox Code Playgroud)

Nothings似乎有效.任何遇到同样问题的人.我仍然希望以前的控制器存活但是改变了UIStatusBarstyle.

xcode statusbar uinavigationcontroller ios uimodalpresentationstyle

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

弹出窗口可见时禁用所有交互

ViewController.modalPresentationStyle = UIModalPresentationPopover;从左侧按钮操作呈现一个弹出控制器(带).在右键按钮动作中,我触发推送segue.理想情况下,当弹出窗口可见时,不应该发生与弹出窗口后面的视图的交互.但是,即使弹出窗口可见,我也可以单击右侧栏按钮并按下新视图控制器而不会忽略弹出窗口.

我的代码是

- (UIViewController *)menuViewController {
    if (!_menuViewController) {
        _menuViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"TableViewController"];
        _menuViewController.modalPresentationStyle = UIModalPresentationPopover;
        UIPopoverPresentationController *popoverPresentationController = _menuViewController.popoverPresentationController;
        popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirectionUp;
    }
    return _menuViewController;
}
- (IBAction)leftAction:(id)sender {
    self.menuViewController.popoverPresentationController.barButtonItem = sender;

    [self presentViewController:self.menuViewController animated:YES completion:nil];
}
- (IBAction)rightAction:(id)sender {
    [self performSegueWithIdentifier:@"PushSegue" sender:nil];
    NSLog(@"Crap here");
}
Run Code Online (Sandbox Code Playgroud)

我尝试将popover表示控制器设置passthroughViews为nill和空数组,但没有结果

如何在弹出窗口可见时禁用所有交互?

更新:

如果弹出窗口可见并且我们在导航栏中有任何交互,则会发生这种情况.简而言之,即使弹出窗口可见,它也会与导航栏进行交互.有没有办法禁用它?

objective-c uipopovercontroller modalviewcontroller ios uimodalpresentationstyle

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

UIPopoverPresentationController在iPhone上显示全屏模式

在iPad上,UIPopoverPresentationController可以正常工作,但在iPhone上,它始终显示全窗口模式弹出窗口。我正在使用以下代码:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
MySecondViewController *contentVC = [storyboard instantiateViewControllerWithIdentifier:@"Pop"];
contentVC.modalPresentationStyle = UINavigationControllerOperationPop; // 13
UIPopoverPresentationController *popPC = contentVC.popoverPresentationController; // 14
contentVC.popoverPresentationController.sourceRect =CGRectMake(100, 130, 280, 230);
self.navigationController.preferredContentSize = CGSizeMake(200, self.parentViewController.childViewControllers.lastObject.preferredContentSize.height-100);
//self.showPop.frame; // 15
contentVC.popoverPresentationController.sourceView =
self.showPop; // 16
popPC.permittedArrowDirections = UIPopoverArrowDirectionAny; // 17
popPC.delegate = self; //18
[self presentViewController:contentVC animated:YES completion:nil];

-(UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller {
    return UIModalPresentationNone;
}
Run Code Online (Sandbox Code Playgroud)

iphone objective-c ios uimodalpresentationstyle

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

iOS 13中的modalPresentationStyle默认值

根据Apple文档,

此属性的默认值为UIModalPresentationStyle.automatic

在iOS 12中,默认值为UIModalPresentationStyle.fullScreen,这就是我得到的。

但是当我在iOS 13上运行我的应用程序时 .pageSheet as navigationController.modalPresentationStyle

我做错了什么吗,还是默认值为.pageSheet?

uiviewcontroller ios uimodalpresentationstyle swift

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

Google 和 Facebook 登录控制器在 Xcode 11 iOS 13 中以模态呈现

我已将 Pod 更新到最新版本,并且

覆盖方法

override func present(_ viewControllerToPresent: UIViewController,
                      animated flag: Bool,
                      completion: (() -> Void)? = nil) {
  viewControllerToPresent.modalPresentationStyle = .fullScreen
  super.present(viewControllerToPresent, animated: flag, completion: completion)
}
Run Code Online (Sandbox Code Playgroud)

所有其他控制器都显示全屏,但 Google 和 Facebook 登录仍显示为页表。

我如何像以前一样全屏显示它们?

脸书登录截图 谷歌登录截图

提前致谢!

更新

我找到了一个解决方法。如果我将我的 LoginViewController 设置为窗口的 rootViewController,那么它们会呈现全屏,但是如果我从 UINavigationController 呈现它们,那么它们会以模态呈现。

    func showSignUpScreen() {
      let controller:SignUpViewController =   UIStoryboard.instantiateViewController(storyboardName: .loginSignup, viewControllerIdetifier: "SignUpViewController") 
      self.navigationController?.interactivePopGestureRecognizer?.isEnabled = false

      //Presents full Screen
      UIApplication.shared.delegate?.window??.rootViewController = controller

      //Presents Modally
      self.navigationController?.pushViewController(controller, animated: false)
}
Run Code Online (Sandbox Code Playgroud)

但是我不能总是显示,因为 Tab Bar 在窗口上显示时会被隐藏。我需要标签栏来显示不需要登录的其他屏幕。

标签栏 呈现在窗口

uiviewcontroller uimodalpresentationstyle swift ios13 xcode11

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

如何使用UIModalPresentationPageSheet调整modalViewController的大小

我有一个模态视图控制器,我用UIModalPresentationPageSheet显示.问题是他的默认大小对我的内容来说太大了:所以我想调整大小是根据我的内容进行调整.

有没有人知道这样做的方法/技巧?

谢谢

frame ipad modalviewcontroller uimodalpresentationstyle cgrect

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

PresentModalViewController与一些框架

我想呈现一个带有小框架的modalViewController并位于视图的中心.

那可能吗?

即使我将一些框架设置为viewController对象,presentModelViewController也会以全屏模式显示该视图.

另外,我使用了modalPresentationStyle作为UIModalPresentationFormSheet.我希望框架比这更小.

怎么做?

iphone presentmodalviewcontroller ios uimodalpresentationstyle

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

使用modalPresentationStyle时如何关闭iPad上的键盘

对于我的iPad应用程序,当按下按钮时,我有一个以模态显示的视图作为表单.为了让键盘在文本字段中输入文本后被解雇,我按照建议进行了尝试;

"disablesAutomaticKeyboardDismissal"方法.

这不起作用,实际上,该方法永远不会根据日志调用.键盘将解除iPhone或我选择不提供模态.

这是我的代码:

- (BOOL)disablesAutomaticKeyboardDismissal
{  
    NSLog(@"method calls");
    return NO;
}

- (IBAction)showNewView:(id)sender
{

    MyViewController *mvc = 
            [[MyViewController alloc] init];

// some lines about setting content
//...

    UINavigationController *navController = [[UINavigationController alloc] 
                                initWithRootViewController:mvc];

    [navController setModalPresentationStyle:UIModalPresentationFormSheet];
    [self presentViewController:navController animated:YES completion:nil];
}
Run Code Online (Sandbox Code Playgroud)

- (BOOL)disablesAutomaticKeyboardDismissal 与否,键盘不会被解除,除非我删除tis行:

    // [navController setModalPresentationStyle:UIModalPresentationFormSheet];
Run Code Online (Sandbox Code Playgroud)

然而,它不再以我想要的方式呈现.

谁能看到我做错了什么?

keyboard uitextfield ipad dismiss uimodalpresentationstyle

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