title: iOS 9 crash when presenting UIActivityViewController : [UIView _fromWindowOrientation] unrecognized selector sent to instance (UIView)
body: <p>My app is crashing any time I present a <code>UIActivityViewController</code>, only on iOS9.</p>
  
  <p>I've isolated the code down to this: (Cleared everything from the AppDelegate minus setting my test view controller as the root and only VC).</p>
  
  <p>In the test view controller on button tap:
  (I made the activityVC an instance property to check if there was a deallocation issue because other debugging efforts suggested that the activityVC might get dealloced during presentation)</p>
  
  <pre><code>NSString *string = @"PLS WORK";
  
  self.activityViewController =
  [[UIActivityViewController alloc] initWithActivityItems:@[string]
                                    applicationActivities:nil];
  
  [self presentViewController:self.activityViewController
                     animated:YES
                   completion:nil];
  </code></pre>
  
  <p>yields </p>
  
  <pre><code>2015-09-21 11:41:55.889 App[21548:606985] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView
  _fromWindowOrientation]: unrecognized selector sent to instance 0x7f9168f25760'
  *** First throw call stack: (   0   CoreFoundation                      0x000000010c68df65 __exceptionPreprocess + 165  1   libobjc.A.dylib    0x000000010be08deb objc_exception_throw + 48     2   CoreFoundation       0x000000010c69658d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205   3   CoreFoundation                      0x000000010c5e3f7a
  ___forwarding___ + 970  4   CoreFoundation                      0x000000010c5e3b28 _CF_forwarding_prep_0 + 120  5   UIKit              0x000000010b104aa0 -[_UIViewControllerTransitionContext
  _affineTransform] + 132     6   UIKit                               0x000000010b104c77 -[_UIViewControllerTransitionContext targetTransform] + 29   7   UIKit                               0x000000010b10895f -[_UIViewControllerTransitionCoordinator targetTransform] + 40   8   UIKit                               0x000000010b109483 _UIViewControllerTransitionCoordinatorIsRotating + 35    9   UIKit                               0x000000010a8fbcba
  -[UIViewController viewWillTransitionToSize:withTransitionCoordinator:] + 78    10  UIKit   0x000000010aa5e68d __79-[UIAlertController
  _contentViewControllerWillTransitionToSize:withAnimations:]_block_invoke591
  + 154   11  UIKit                               0x000000010a7faeec +[UIView(Animation) performWithoutAnimation:] + 65   12  UIKit                               0x000000010b03b693 -[_UIAnimationCoordinator animate] + 128     13  UIKit 0x000000010aa5e54d -[UIAlertController
  _contentViewControllerWillTransitionToSize:withAnimations:] + 1071  14  UIKit                               0x000000010b0d2910
  -[_UIAlertControllerView _sizeOfContentViewControllerChanged] + 1009    15  UIKit                               0x000000010aa5afe8
  -[UIAlertController viewDidLoad] + 659  16  UIKit                               0x000000010a8e0931 -[UIViewController loadViewIfRequired] + 1344    17  UIKit                               0x000000010a8e0c7d
  -[UIViewController view] + 27   18  UIKit                               0x000000010b0292ab -[UIActivityViewController viewDidLoad] + 1266   19  UIKit                               0x000000010a8e0931
  -[UIViewController loadViewIfRequired] + 1344   20  UIKit                               0x000000010a8e0c7d -[UIViewController view] + 27    21  UIKit            0x000000010a8fa738 -[UIViewController _setPresentationController:] + 100   22  UIKit                               0x000000010a8f1cf4
  -[UIViewController _presentViewController:modalSourceViewController:presentationController:animationController:interactionController:completion:]
  + 1437  23  UIKit                               0x000000010a8f3970 -[UIViewController _presentViewController:withAnimationController:completion:] + 4870    24  UIKit                               0x000000010a8f6878
  -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 489     25  UIKit                               0x000000010a8f6387
  -[UIViewController presentViewController:animated:completion:] + 179    26  App                             0x0000000107607734
  -[YYWTFViewController wtfButtonPressed:] + 644  27  UIKit                               0x000000010a7571fa -[UIApplication sendAction:to:from:forEvent:] + 92   28  UIKit                               0x000000010a8bb504
  -[UIControl sendAction:to:forEvent:] + 67   29  UIKit                               0x000000010a8bb7d0 -[UIControl _sendActionsForEvents:withEvent:] + 311  30  UIKit                               0x000000010a8ba906
  -[UIControl touchesEnded:withEvent:] + 601  31  UIKit                               0x000000010a7c1aa3 -[UIWindow _sendTouchesForEvent:] + 835  32  UIKit  0x000000010a7c2691 -[UIWindow sendEvent:] + 865  33  UIKit             0x000000010a774752 -[UIApplication sendEvent:] + 263  34  UIKit        0x000000010a74ffcc _UIApplicationHandleEventQueue + 6693   35  CoreFoundation                      0x000000010c5ba0a1
  __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17     36  CoreFoundation                      0x000000010c5affcc
  __CFRunLoopDoSources0 + 556     37  CoreFoundation                      0x000000010c5af483 __CFRunLoopRun + 867     38  CoreFoundation            0x000000010c5aee98 CFRunLoopRunSpecific + 488     39  GraphicsServices    0x000000010f0d9ad2 GSEventRunModal + 161    40  UIKit                    0x000000010a755676 UIApplicationMain + 171     41  App                    0x000000010766101f main + 111    42  libdyld.dylib                       0x000000010d98792d start + 1 )
  </code></pre>
  
  <p>Assembler crash log:</p>
  
  <pre><code>0x10a7555cb &lt;+0&gt;:   pushq  %rbp
  0x10a7555cc &lt;+1&gt;:   movq   %rsp, %rbp
  0x10a7555cf &lt;+4&gt;:   pushq  %r15
  0x10a7555d1 &lt;+6&gt;:   pushq  %r14
  0x10a7555d3 &lt;+8&gt;:   pushq  %r13
  0x10a7555d5 &lt;+10&gt;:  pushq  %r12
  0x10a7555d7 &lt;+12&gt;:  pushq  %rbx
  0x10a7555d8 &lt;+13&gt;:  pushq  %rax
  0x10a7555d9 &lt;+14&gt;:  movq   %rcx, %rbx
  0x10a7555dc &lt;+17&gt;:  movq   %rsi, %r15
  0x10a7555df &lt;+20&gt;:  movl   %edi, %r12d
  0x10a7555e2 &lt;+23&gt;:  movq   0xcc7ba7(%rip), %r13      ; (void *)0x000000010be1bd00: objc_retain
  0x10a7555e9 &lt;+30&gt;:  movq   %rdx, %rdi
  0x10a7555ec &lt;+33&gt;:  callq  *%r13
  0x10a7555ef &lt;+36&gt;:  movq   %rax, %r14
  0x10a7555f2 &lt;+39&gt;:  movq   %rbx, %rdi
  0x10a7555f5 &lt;+42&gt;:  callq  *%r13
  0x10a7555f8 &lt;+45&gt;:  movq   %rax, %r13
  0x10a7555fb &lt;+48&gt;:  leaq   0xcc5aea(%rip), %rbx      ; _UIApplicationLinkedOnVersion
  0x10a755602 &lt;+55&gt;:  movl   (%rbx), %eax
  0x10a755604 &lt;+57&gt;:  testl  %eax, %eax
  0x10a755606 &lt;+59&gt;:  jne    0x10a755627               ; &lt;+92&gt;
  0x10a755608 &lt;+61&gt;:  cmpq   $-0x1, 0xcc18a0(%rip)     ; WebKitSetIsClassic + 7
  0x10a755610 &lt;+69&gt;:  je     0x10a755651               ; &lt;+134&gt;
  0x10a755612 &lt;+71&gt;:  leaq   0xcc1897(%rip), %rdi      ; _UIApplicationLinkedOnVersionOnce
  0x10a755619 &lt;+78&gt;:  leaq   0xccaeb0(%rip), %rsi      ; __block_literal_global1457
  0x10a755620 &lt;+85&gt;:  callq  0x10b1a3f5c               ; symbol stub for: dispatch_once
  0x10a755625 &lt;+90&gt;:  movl   (%rbx), %eax
  0x10a755627 &lt;+92&gt;:  cmpl   $0x20100, %eax
  0x10a75562c &lt;+97&gt;:  jb     0x10a755651               ; &lt;+134&gt;
  0x10a75562e &lt;+99&gt;:  callq  0x10b1a3746               ; symbol stub for: objc_autoreleasePoolPush
  0x10a755633 &lt;+104&gt;: movq   %rax, %rbx
  0x10a755636 &lt;+107&gt;: movl   %r12d, %edi
  0x10a755639 &lt;+110&gt;: movq   %r15, %rsi
  0x10a75563c &lt;+113&gt;: movq   %r14, %rdx
  0x10a75563f &lt;+116&gt;: movq   %r13, %rcx
  0x10a755642 &lt;+119&gt;: callq  0x10a755698               ; _UIApplicationMainPreparations
  0x10a755647 &lt;+124&gt;: movq   %rbx, %rdi
  0x10a75564a &lt;+127&gt;: callq  0x10b1a3740               ; symbol stub for: objc_autoreleasePoolPop
  0x10a75564f &lt;+132&gt;: jmp    0x10a755662               ; &lt;+151&gt;
  0x10a755651 &lt;+134&gt;: movl   %r12d, %edi
  0x10a755654 &lt;+137&gt;: movq   %r15, %rsi
  0x10a755657 &lt;+140&gt;: movq   %r14, %rdx
  0x10a75565a &lt;+143&gt;: movq   %r13, %rcx
  0x10a75565d &lt;+146&gt;: callq  0x10a755698               ; _UIApplicationMainPreparations
  0x10a755662 &lt;+151&gt;: movq   0xcc59df(%rip), %rdi      ; UIApp
  0x10a755669 &lt;+158&gt;: movq   0xc4a3c8(%rip), %rsi      ; "_run"
  0x10a755670 &lt;+165&gt;: callq  *0xcc7b0a(%rip)           ; (void *)0x000000010be1e800: objc_msgSend
  0x10a755676 &lt;+171&gt;: movq   0xcc7b0b(%rip), %rbx      ; (void *)0x000000010be1bd70: objc_release &lt;--- DEAD
  </code></pre>
  
  <p>What is odd is that creating a new project targeted for iOS9 with the exact same code does not crash. I don't know how I can isolate this issue in my project any further. I'd appreciate any hints or debugging suggestions!</p>