【问题标题】:Actionsheet popover background truns to black before popover gets dismissed in ios 9在 ios 9 中的弹出框消失之前,操作表弹出框背景变为黑色
【发布时间】:2015-09-29 11:10:21
【问题描述】:

使用以下:

  [self.actionSheetPostOptions showFromBarButtonItem:self.navigationItem.rightBarButtonItem animated:YES];

也试过了

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil
                                                                       message:nil
                                                                preferredStyle:UIAlertControllerStyleActionSheet];

UIAlertAction *actnCamera = [UIAlertAction actionWithTitle:@"Camera" style:UIAlertActionStyleDefault
                                                    handler:^(UIAlertAction * action) {
                                                 }];

UIAlertAction *actnLibrary = [UIAlertAction actionWithTitle:@"Library" style:UIAlertActionStyleDefault
                                                 handler:^(UIAlertAction * action) {
                                                 }];

[alertController addAction:actnLibrary];
[alertController addAction:actnCamera];
[alertController setModalPresentationStyle:UIModalPresentationPopover];
UIPopoverPresentationController *popPresenter = [alertController
                                                             popoverPresentationController];
popPresenter.barButtonItem = self.navigationItem.rightBarButtonItem;
[self presentViewController:alertController animated:YES completion:nil];

但在解雇时仍然遇到同样的问题。

更新iOS 11:iOS 11 中不再存在此问题。

【问题讨论】:

  • 有同样的问题。对我来说,当我将位置从屏幕右侧更改为左侧时,它工作正常。有更新吗?
  • 在我的情况下,Popover 应该只来自右键。所以添加了一个解决方法,禁用演示文稿上的视图动画。解雇后重新启用。它解决了我的问题。
  • 这里有同样的问题。你是如何禁用视图动画的?
  • 使用 [UIView setAnimationsEnabled:NO];在 UIAlertController 的演示文稿中禁用动画并在关闭时启用 ([UIView setAnimationsEnabled:YES];)。
  • 尝试出现在主队列中

标签: objective-c ios9


【解决方案1】:

你在真机上也试过了吗?我在 iOS 模拟器中运行时看到了相同的行为,但在设备上它工作正常。

【讨论】:

  • 仅限我的设备问题。在模拟器中工作正常。
【解决方案2】:

我为此添加了解决方法,方法是禁用操作表演示文稿上的视图动画并在关闭工作表后启用。

在显示 UIAlertController 之前使用下面禁用视图动画。

 [UIView setAnimationsEnabled:NO]; 

并在 UIAlertController 关闭后启用视图动画。

 [UIView setAnimationsEnabled:YES];

当然,这不是一个解决方案,但它可能会有所帮助。

【讨论】:

  • iOS 11 更新:iOS 11 不再存在此问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-02-01
  • 2011-08-12
  • 1970-01-01
  • 2014-02-24
  • 1970-01-01
  • 2015-05-06
相关资源
最近更新 更多