4

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];

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.

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.

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

[activityViewController.view setTranslatesAutoresizingMaskIntoConstraints:NO];

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

Community
  • 1
  • 1
Jonathan
  • 606
  • 5
  • 19
  • I have the similar problem and looks like there is no solution for it yet. You must compile the project with iOS 8.x SDK and all will work on iOS 7.x without any problems, if your project minimum allowed version is 7.x – Ivan Lisovyi Nov 04 '14 at 15:21
  • This is happening to me while compiling on 8.x iPad. do you know where thats coming from yet? – Ace Green Jun 30 '15 at 05:06

1 Answers1

13

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);
kamus
  • 797
  • 1
  • 6
  • 15
archdemo
  • 131
  • 1
  • 3
  • 2
    I had the issue only on iPad - and still in iOS resp. iPadOS 13. The App does not crash, but the Activity Controller doesn't show up. Defining the CGRect, like in this answer, fixed the Problem and the Controller appears correctly. – ZAY Jan 25 '20 at 17:07
  • 1
    This is still very much an Issue... sadly.. this does appear to resolve it. – Speckpgh Jun 03 '20 at 15:51
  • Still not fixed with Xcode 14.2 and iOS 16.2 – AfnanAhmad Jan 11 '23 at 07:05