gpt4 book ai didi

ipad - 在 iPad 上显示的 UIDocumentMenuViewController 给出 "Unable to simultaneously satisfy constraints"

转载 作者:行者123 更新时间:2023-12-01 09:22:29 25 4
gpt4 key购买 nike

我在从 iPad 上的条形按钮项目中显示 UIDocumentMenuViewController 时遇到一些问题。我确实得到了正确的初始行为,并且根据需要从 barButtonItem 调用了菜单,但是在调用委托(delegate)之前,我收到了一些我不确定如何修复的自动布局约束消息。这就是我调用 UIDocumentMenu VC 的方式:

UIDocumentMenuViewController *documentMenu = [[UIDocumentMenuViewController alloc] initWithDocumentTypes:[self fileUTIList] inMode:UIDocumentPickerModeImport];
documentMenu.delegate = self;
documentMenu.modalPresentationStyle = UIModalPresentationPopover;
documentMenu.popoverPresentationController.barButtonItem = self.rightAddButton;
//documentMenu.popoverPresentationController.sourceView = self.view;
//documentMenu.should have a non-nil sourceView or barButtonItem set before the presentation occurs
[self presentViewController: documentMenu animated:YES completion: ^{
NSLog(@"DocumentPicker presented completion");
}];

我得到上面的完成处理程序被正确调用,它在 iPad 上看起来很好。但是当我为菜单选择一个项目时,我立即收到“无法同时满足约束”消息:
2014-10-22 22:42:20.817 iPad[34421:474588] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSLayoutConstraint:0x7c1d0f30 H:[UIView:0x7c1cbc20(304)]>",
"<NSLayoutConstraint:0x7c1ddbf0 _UIAlertControllerView:0x7c1cbc90.width == UIView:0x7c1ca670.width>",
"<NSLayoutConstraint:0x7c14b310 'UIView-Encapsulated-Layout-Width' H:[UIView:0x7c1ca670(142)]>",
"<NSLayoutConstraint:0x7c151a80 _UIAlertControllerView:0x7c1cbc90.width >= UIView:0x7c1cbc20.width>"
)

Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7c1d0f30 H:[UIView:0x7c1cbc20(304)]>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2014-10-22 22:42:20.818 iPad[34421:474588] documentMenu: didPickDocumentPicker

然后最终调用了 documentMenu 的委托(delegate),并呈现了 UIDocumentPickerViewController,看起来是正确的:
- (void)documentMenu:(UIDocumentMenuViewController *)documentMenu didPickDocumentPicker:(UIDocumentPickerViewController *)documentPicker {
NSLog(@"documentMenu: didPickDocumentPicker");
documentPicker.delegate = self;
[self presentViewController:documentPicker animated:YES completion:nil];

但我担心如果我附带这个会产生影响并导致一些奇怪的显示问题。有什么方法可以确定究竟是什么导致了这种行为,因为它似乎来自 UIDocumentMenuViewController/UIAlertControllerView?

最佳答案

iPad 有一些关于 ActionSheets 及其取消按钮的特殊规则,这通常取决于您从哪里显示 ActionSheets,因此您可以通过以下方式解决崩溃问题:

let importMenu = UIDocumentMenuViewController(documentTypes: [kUTTypeHTML as String ], in: .import)
importMenu.delegate = self
importMenu.modalPresentationStyle = .popover
importMenu.popoverPresentationController?.sourceView = self.view
self.present(importMenu, animated: true, completion: nil)

关于ipad - 在 iPad 上显示的 UIDocumentMenuViewController 给出 "Unable to simultaneously satisfy constraints",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26522031/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com