我正在尝试在我当前呈现的视图控制器上显示消息撰写视图控制器,但应用程序在MFMessageComposeViewController
演示动画中间崩溃。使用以下代码显示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];
此处contactDetails.title
和aContactRef.contact
返回NSString
同样在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];
在这两种情况下,应用程序崩溃并出现错误
*** 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>'
此处archiveViewController
是试图呈现UIAlertController
/ MFMessageComposeViewController
有时也会在上述消息之前显示此消息(如果出现MFMessageComposeViewController
)
<CKSMSComposeRemoteViewController: 0x170d8400> timed out waiting for fence barrier from com.apple.mobilesms.compose
我怀疑这个问题与我archiveViewController
的设置有关,但是在呈现其他视图控制器时不会发生这种情况,例如:(这些确实存在)
MFMailComposeViewController
UIAlertControllerStyle
更改为UIAlertControllerStyleActionSheet
UIViewController
的任何实例
请询问任何问题以获取更多信息。谢谢你看看。