0

I'm trying to present a message compose view controller on my currently presented view controller but the app crashes in the middle of the MFMessageComposeViewController presentation animation. using the following code to present the MFMessageComposeViewController

MFMessageComposeViewController *newComposer=[[MFMessageComposeViewController alloc]init];
            newComposer.messageComposeDelegate=self;
            newComposer.body=contactDetails.title;
            NSMutableArray *arrayForRecipients;
            for (int i=0; i<contactDetails.recipients.count; i++)
            {
                ArchivedAddedContacts *aContactRef=[contactDetails.recipients objectAtIndex:i];
                if (!arrayForRecipients) arrayForRecipients=[[NSMutableArray alloc]init];
                [arrayForRecipients addObject:aContactRef.contact];
            }
            [newComposer setRecipients:arrayForRecipients];
            [self presentViewController:newComposer animated:YES completion:NULL];

here contactDetails.title and aContactRef.contact return an NSString

Similarly in case of UIAlertController:

UIAlertController * Alert1=[UIAlertController alertControllerWithTitle:@"This device can't make calls" message:nil preferredStyle:UIAlertControllerStyleAlert];
                UIAlertAction *actionOK=[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleCancel handler:nil];
                [Alert1 addAction:actionOK];
                [self presentViewController:Alert1 animated:YES completion:nil];

In both the case the app crashes with the error

*** Terminating app due to uncaught exception 'UIViewControllerHierarchyInconsistency', reason: 'child view controller:<UICompatibilityInputViewController: 0x156e1560> should have parent view controller:<archiveViewController: 0x156a4c60> but requested parent is:<UIInputWindowController: 0x1645f600>'

here archiveViewController is the view controller that is trying to present the UIAlertController/MFMessageComposeViewController

And sometimes also show this message before the above one (in case of presenting MFMessageComposeViewController)

<CKSMSComposeRemoteViewController: 0x170d8400> timed out waiting for fence barrier from com.apple.mobilesms.compose

I suspected the issue to be related to my setting up of archiveViewController but this does not happen in case of presenting other view controllers like: (these do present successfully)

  • MFMailComposeViewController
  • changing UIAlertControllerStyle to UIAlertControllerStyleActionSheet
  • presenting any instance of UIViewController created in code
  • presenting a view controller modally setup in storyboard

Do ask any question for more info. Thanks for taking a look.

Ishaan Sejwal
  • 660
  • 9
  • 29
  • I've just stumbled across exactly this error in presenting a properly formatted UIAlertController. Changing the style to an 'UIAlertControllerStyleActionSheet' silenced the error. Do you have any update? – Peter Brockmann Apr 27 '15 at 15:44
  • Yeah I was able to solve the problem but, it was a very hit and try weird solution so didnt answer my question here. The culprit seemed to be a UIView that i added in the view controller's (the UIViewController trying to present UIAlertController) storyboard. What i did was removed it from the storyboard along with its @property outlet connection in my UIViewController subclass. and then programmatically create and rearrange and add subviews to it in code. – Ishaan Sejwal Apr 27 '15 at 16:02
  • So i would recommend you remove all subviews individually that you added in the view controller storyboard and run the app and check if UIAlertController is being presented successfully. And if you are able to find the culprit `@property` declaration of that UIView then connect it in your file as an ivar and not a `@property` or simply just create it as an ivar in code in the first place. Very weird behaviour but this is how i did it. – Ishaan Sejwal Apr 27 '15 at 16:05

0 Answers0