UIActivityViewController,为iOS 7.x编译时,无法同时满足设备8.x上的约束 [英] UIActivityViewController, Unable to simultaneously satisfy constraints, on devices 8.x when compiled for iOS 7.x

查看:78
本文介绍了UIActivityViewController,为iOS 7.x编译时,无法同时满足设备8.x上的约束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UIActivityViewController,显示在UIViewController上(此处命名为viewCon):

I have an UIActivityViewController that is shown on an UIViewController (named viewCon here) :

// items contains text and/or image
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:nil];
activityViewController.excludedActivityTypes = @[UIActivityTypePostToWeibo, UIActivityTypeAssignToContact];

[viewCon presentViewController:activityViewController animated:YES completion:NULL];

我正在使用Xcode 6.1.我的应用程序的部署目标为7.0.我在两部物理iPhone(5S(8.0.2)和6(8.1))上运行它.
当我在物理设备上(而不是在模拟器上)编译适用于iOS 7.x的应用程序时,会显示并显示UIActivityViewController并且可以在所有屏幕上显示UIActivityViewController(高度过大),并且该日志消息会打印在输出:

I'm using Xcode 6.1. My app has a Deployment Target to 7.0. I run it on two physical iPhones (5S (8.0.2) and 6 (8.1)).
When I compile my app for iOS 7.x on a physical device (not on simulators), the UIActivityViewController is shown and works but it appears on all the screen (the height is too big) and this log messages are printed in the Output :

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)-[UIView:0x170385960]   (Names: '|':_UIAlertControllerView:0x134ef4fc0 )>",
"<NSLayoutConstraint:0x17429a270 UIView:0x170385960.bottom <= _UIAlertControllerView:0x134ef4fc0.bottom>",
"<NSLayoutConstraint:0x174292cf0 UIView:0x174385960.centerY == UIView:0x170385960.centerY>",
"<NSLayoutConstraint:0x174294410 V:|-(>=8)-[UIView:0x174385960]   (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.

当我为iOS 8.x编译并运行时,一切正常.但是,当然,我需要为iOS 7.x进行编译以实现兼容性.
UIViewController使用使用自动布局的.xib.但是我尝试不使用自动版式,并且出现相同的问题.我尝试了另外两个项目,也在iOS 7上进行了尝试,并且仍然相同.

When I compile and run for iOS 8.x everything works well. But of course I need to compile for iOS 7.x for compatibility.
The UIViewController uses a .xib that use Autolayout. But I tried to not use Autolayout and the same issue appear. I tried in two other projects, also on iOS 7 and it's still the same.

我还尝试在显示activityViewController之前添加此代码,但存在相同的问题:

I also tried to add this code before presenting the activityViewController, but same issue :

[activityViewController.view setTranslatesAutoresizingMaskIntoConstraints:NO];

我看到其他开发人员也遇到了同样的问题(此处 ),但它是由Xcode 6 beta引起的.我的版本是6.1.

I saw that others developers had the same issue (here) but it was caused by Xcode 6 beta. I've the version 6.1.

推荐答案

我猜这是一个iOS7错误. 它带有一些特殊的sourceRect值. 您可以通过设置另一个sourceRect来解决它,例如,您可以尝试:

I guess this is an iOS7 bug. It appears with some special sourceRect value. You can fix it by set another sourceRect, for example you can try:

[activityView popoverPresentationController].sourceRect=CGRectMake( 0,200,768,20);

这篇关于UIActivityViewController,为iOS 7.x编译时,无法同时满足设备8.x上的约束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆