ios - UIActivityViewController,在为 iOS 7.x 编译时在设备 8.x 上无法同时满足约束
<p><p>我有一个 <code>UIActivityViewController</code> 显示在 <code>UIViewController</code> 上(此处命名为 viewCon):</p>
<pre><code>// items contains text and/or image
UIActivityViewController *activityViewController = [ initWithActivityItems:items applicationActivities:nil];
activityViewController.excludedActivityTypes = @;
;
</code></pre>
<p>我使用的是 Xcode 6.1。我的应用程序的部署目标为 7.0。我在两部物理 iPhone(5S (8.0.2) 和 6 (8.1))上运行它。<br/>
当我在物理设备(而不是模拟器)上为 iOS 7.x 编译我的应用程序时,<code>UIActivityViewController</code> 会显示并且可以工作,但它会出现在所有屏幕上(高度太大)和此日志消息打印在输出中:</p>
<pre><code>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:0x1742941e0 UIView:0x174385960.bottom == _UIAlertControllerView:0x134ef4fc0.bottom>",
"<NSLayoutConstraint:0x174293d80 V:|-(0)- (Names: '|':_UIAlertControllerView:0x134ef4fc0 )>",
"<NSLayoutConstraint:0x17429a270 UIView:0x170385960.bottom <= _UIAlertControllerView:0x134ef4fc0.bottom>",
"<NSLayoutConstraint:0x174292cf0 UIView:0x174385960.centerY == UIView:0x170385960.centerY>",
"<NSLayoutConstraint:0x174294410 V:|-(>=8)- (Names: '|':_UIAlertControllerView:0x134ef4fc0 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x17429a270 UIView:0x170385960.bottom <= _UIAlertControllerView:0x134ef4fc0.bottom>
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.
</code></pre>
<p>当我为 iOS 8.x 编译和运行时,一切正常。但是为了兼容,我当然需要为 iOS 7.x 编译。<br/>
<code>UIViewController</code> 使用一个使用 Autolayout 的 .xib。但是我尝试不使用 Autolayout 并且出现了同样的问题。我尝试了另外两个项目,也在 iOS 7 上,它仍然是一样的。 </p>
<p>我也尝试在展示 activityViewController 之前添加此代码,但同样的问题:</p>
<pre><code>;
</code></pre>
<p>我看到其他开发人员也有同样的问题 (<a href="https://stackoverflow.com/questions/25891574/how-to-change-the-size-the-uiactivityviewcontroller" rel="noreferrer noopener nofollow">here</a>),但这是由 Xcode 6 beta 引起的。我有 6.1 版。</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>我猜这是 iOS7 的错误。
它带有一些特殊的 <code>sourceRect</code> 值。
您可以通过设置另一个 <code>sourceRect</code> 来修复它,例如您可以尝试:</p>
<pre><code>.sourceRect=CGRectMake( 0,200,768,20);
</code></pre></p>
<p style="font-size: 20px;">关于ios - UIActivityViewController,在为 iOS 7.x 编译时在设备 8.x 上无法同时满足约束,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/26623893/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/26623893/
</a>
</p>
页:
[1]