• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ios - UIActivityViewController,在为 iOS 7.x 编译时在设备 8.x 上无法同时满足约束

[复制链接]
菜鸟教程小白 发表于 2022-12-12 12:23:58 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

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

// 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 会显示并且可以工作,但它会出现在所有屏幕上(高度太大)和此日志消息打印在输出中:

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 使用一个使用 Autolayout 的 .xib。但是我尝试不使用 Autolayout 并且出现了同样的问题。我尝试了另外两个项目,也在 iOS 7 上,它仍然是一样的。

我也尝试在展示 activityViewController 之前添加此代码,但同样的问题:

[activityViewController.view setTranslatesAutoresizingMaskIntoConstraints:NO];

我看到其他开发人员也有同样的问题 (here),但这是由 Xcode 6 beta 引起的。我有 6.1 版。



Best Answer-推荐答案


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

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

关于ios - UIActivityViewController,在为 iOS 7.x 编译时在设备 8.x 上无法同时满足约束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26623893/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap