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
toUIAlertControllerStyleActionSheet
- 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.