title: Composing mail in iOS 7 : Assertion failure in -[MFComposeSubjectView layoutSublayersOfLayer:]
body: <p>I am currently running in troubles with iOS7 and the <code>MFMailComposeViewController</code>. Sometimes (quite often but not always), I have the following crash when presenting the <code>MFMailComposeViewController</code>: </p>
  
  <blockquote>
    <p>** * Assertion failure in -[MFComposeSubjectView layoutSublayersOfLayer:], /SourceCache/UIKit/UIKit-2903.23/UIView.m:8540</p>
  </blockquote>
  
  <p>Here is how I present the controller:</p>
  
  <pre><code>if ([MFMailComposeViewController canSendMail])
      {
          MFMailComposeViewController* mailVC = [[MFMailComposeViewController alloc] initWithNibName:nil bundle:nil];
          mailVC.mailComposeDelegate = self;
  
          [mailVC setSubject:@"blablabla"]];
          [mailVC setMessageBody:@"blablabla" isHTML:NO]; 
          mailVC.modalPresentationStyle = UIModalPresentationFormSheet;
          mailVC.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
  
          if(isIpad) {
              [sharedParentViewController presentViewController:mailVC animated:YES completion:nil];
          } else {
              [sharedNavigationViewController presentViewController:mailVC animated:YES completion:nil];
          }
      }
  </code></pre>
  
  <p><code>sharedParentViewController</code> and <code>sharedNavigationViewController</code> are defined macros to access root view controller everywhere in the app.</p>
  
  <p>I set up a breakpoint on all exceptions but unfortunately, it never breaks.</p>
  
  <p>With iOS6 and iOS5, everything works fine, any idea of what I can try to fix this?</p>
  
  <p>EDIT:</p>
  
  <p>Here is the crash log:</p>
  
  <pre><code>Stack Trace
  
  Auto Layout still required after executing -layoutSubviews. MFComposeSubjectView's implementation of -layoutSubviews needs to call super.
  
  0   CoreFoundation                      0x3099ff4b &amp;lt;redacted&amp;gt; + 130
  1   libobjc.A.dylib                     0x3b1366af objc_exception_throw + 38
  2   CoreFoundation                      0x3099fe25 &amp;lt;redacted&amp;gt; + 0
  3   Foundation                          0x31347fe3 &amp;lt;redacted&amp;gt; + 90
  4   UIKit                               0x33112e63 &amp;lt;redacted&amp;gt; + 538
  5   QuartzCore                          0x32d99c6b &amp;lt;redacted&amp;gt; + 142
  6   QuartzCore                          0x32d9547b &amp;lt;redacted&amp;gt; + 350
  7   QuartzCore                          0x32d9530d &amp;lt;redacted&amp;gt; + 16
  8   QuartzCore                          0x32d94d1f &amp;lt;redacted&amp;gt; + 230
  9   QuartzCore                          0x32d94b2f &amp;lt;redacted&amp;gt; + 314
  10  QuartzCore                          0x32d8e85d &amp;lt;redacted&amp;gt; + 56
  11  CoreFoundation                      0x3096b1cd &amp;lt;redacted&amp;gt; + 20
  12  CoreFoundation                      0x30968b71 &amp;lt;redacted&amp;gt; + 284
  13  CoreFoundation                      0x30968eb3 &amp;lt;redacted&amp;gt; + 730
  14  CoreFoundation                      0x308d3c27 CFRunLoopRunSpecific + 522
  15  CoreFoundation                      0x308d3a0b CFRunLoopRunInMode + 106
  16  GraphicsServices                    0x355c7283 GSEventRunModal + 138
  17  UIKit                               0x33177049 UIApplicationMain + 1136
  18  teleobs                             0x00037921 main + 116
  19  teleobs                             0x000378a8 start + 40
  </code></pre>