2014-05-21 3 views
1

SMS를 보내는 데 다음 기능을 사용하고 있습니다. 그것은 아이폰 OS 7에서 잘 작동과 above.ButMFMessageComposeViewController가 iOS 6에서 충돌 함

if([MFMessageComposeViewController canSendText]) 
{ 
    MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init]; 
    controller.body = @"SMS Text"; 

    controller.messageComposeDelegate = (id)self; 
    [self presentViewController:controller animated:TRUE completion:nil]; 
} 

오류

과 6.0.1에서 실행되는 아이팟에서 충돌 것

* *있는 NSDictionary * _UIRecordArgumentOfInvocationAtIndex (있는 NSInvocation * NSUInteger에서 어설 션 실패 캐치되지 excepti 인해 응용 프로그램 종료 BOOL *)() /SourceCache/UIKit/UIKit-2372/UIAppearance.m:1118

2014년 5월 21일 11 : 33 : 38.170 프로젝트 [4913 764] 'NSInternalInconsistencyException', 이유에 : (0x36c922a3 0x3346997f 0x36c9215d 0x383b430b 0x37717925 0x37716a7b 0x36c8f62f 0x377167f5 0x377f45e5 0x37782cd7 0x37782b6d 0x359d390f 0x37782a61 0x3778c0d5 0x359c683b 0x3778c0b1 0x359c611f 0x359c599b 0x359c5895 0x359d4215 : * 먼저 던져 호출 스택 '알 수없는 키, 제목 텍스트에서 "NSColor는"사전 속성' 0x359d43b9 0x36163a11 0x361638a4) 는 libc의 ++ abi.dylib :

+0

충돌하는 라인에서 pls 디버깅을 할 수 있습니까? 이것을 시도해보십시오,'[MFMessageComposeViewController canSendText]' – iDeveloper

+0

이 오류에 따르면,'NSForegroundColorAttributeName' 대신에'UITextAttributeTextColor'를 사용해보십시오. – iDeveloper

답변

1

확률 적 이유는 당신의 선택 도구가 nil 것입니다. 이 코드는 텍스트를 보낼 수있는 장치에서만 작동합니다. 이와 관련하여 항상 [MFMessageComposeViewController canSendText]을 사용하여 메시지 전송 기능을 확인한 다음 선택기 만 표시해야합니다.애플의 MFMessageComposeViewController 문서에서 :

Before presenting a message composition view, call the canSendText class method to ensure that the user’s device is appropriately configured. Do not attempt to present a message composition view if the canSendText method returns NO. If SMS delivery isn’t available, you can notify the user or simply disable the SMS features in your application. 

Starting in iOS 5, you can register to be notified of changes to the availability of text message sending by way of the MFMessageComposeViewControllerTextMessageAvailabilityDidChangeNotification notification. 

편집 : 오류를 수정해야 아마 당신의 응용 프로그램에서 UIAppearance 방법을 사용하여 NSForegroundColorAttributeName을 설정하는 곳 는 UITextAttributeTextColor 대신 NSForegroundColorAttributeName 사용.

+0

질문을 수정했습니다.하지만 동일한 오류가 발생했습니다 – Jeff

+0

예외 중단 점을 추가하고 앱을 실행할 수 있습니까? 충돌이 발생하면 프로그램은 충돌을 야기한 범인 선을 표시해야합니다. – akdsouza

+0

업데이트 됨 내 질문 – Jeff

0

당신은 iPod에 SMS를 사용할 수 없습니다 감지 할 수있을 것입니다 예외

에게 어떤 도움을 던지는라는 종료, 그것은 단지 아이폰을위한 것입니다. 당신은 같이해야합니다 : -

MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init]; 

if([MFMessageComposeViewController canSendText]) 
    { 
    //TODO: your other code 
    controller.body = @"SMS Text"; 
    controller.messageComposeDelegate = self; 
    [self presentViewController:picker animated:YES completion:NULL]; 
    } 

당신이 당신의 뷰 컨트롤러의 헤더에 MFMessageComposeViewControllerDelegate를 구현해야합니다. 너무 도움이 될

다음 링크 : -

  1. Weird MFMailComposeViewController Crash
  2. MFMailComposeViewController Crashes because of Global Appearance Properties on iOS6
+0

질문을 수정했습니다. 그러나 동일한 오류가 발생했습니다 – Jeff

+0

왜 유형을 viewcontroller 캐스트하려는? 방금 대답을 업데이트했습니다. – Ricky

0

이 시도 :

if ([MFMessageComposeViewController canSendText]) 
// The device can send sms. 
{ 
    MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init]; 
picker.messageComposeDelegate = self; 

// You can specify one or more preconfigured recipients. The user has 
// the option to remove or add recipients from the message composer view 
// controller. 
// You can specify the initial message text that will appear in the message 
// composer view controller. 

picker.body = @"Hello Text"; 

[self presentViewController:picker animated:YES completion:NULL]; 
} 

당신이 +[MFMessageComposeViewController canSendText]을 확인 했습니까?

참조 :

canSendText

Returns a Boolean value indicating whether the current device is capable of sending text messages. + (BOOL)canSendText 

반환 값

YES if the device can send text messages or NO if it cannot. Discussion 

Always call this method before attempting to present the message compose view controller. A device may be unable to send messages if it does not support messaging or if it is not currently configured to send messages. This method applies only to the ability to send text messages via iMessage, SMS, and MMS. 

To be notified of changes in the availability of sending text messages, register as an observer of the MFMessageComposeViewControllerTextMessageAvailabilityDidChangeNotification notification. Availability 

Available in iOS 4.0 and later. 
Declared In MFMessageComposeViewController.h 
+0

질문을 수정했습니다. 그러나 동일한 오류가 발생했습니다 – Jeff

+0

코드에서 Remove 된 presentViewController가 할당 후 충돌합니다 – Jeff

+0

iMessage가 올바르게 있습니까? – Jeff

관련 문제