呈现MFMessageComposeViewController或UIAlertController会崩溃应用程序

时间:2015-04-16 08:41:54

标签: ios objective-c uiviewcontroller uialertcontroller mfmessagecomposeview

我正在尝试在我当前呈现的视图控制器上显示消息撰写视图控制器,但应用程序在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.titleaContactRef.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的任何实例
  • 在故事板中呈现视图控制器模态设置

请询问任何问题以获取更多信息。谢谢你看看。

0 个答案:

没有答案