2013-09-02 6 views
2

내 앱을 사용자 정의하는 동안 너무 좌절감을 느낍니다. Navigation bar, toolbar, tabBar 등 거의 모든 앱을 만들고 스타일을 지정했지만, MFMailComposeViewController, MFMessageComposerViewController, Twitter 또는 Facebook 공유자 또는 QuickLook View Controller가 재생 될 때마다 앱과 메시지가 충돌합니다 :UIA 보류 및 다양한 충돌

*** Assertion failure in -[UICGColor encodeWithCoder:]. 
*** Terminating app due to uncaught exception 'NSInternalInconsistencyExceptionì, reason: 'Only RGBA or White color spaces are supported in this situation.' 

나는 아이폰 OS 6 원격 컨트롤러와 작곡가를 관리 때문이라고 주위 읽었습니다,하지만 난 정말 방법이 문제에 대한 수정을 얻으려면 어떤 생각을하지 않았습니다.

메일 구성 기능 또는 메시지 작성 기능을 제거하고 싶지 않습니다.

누구든지이 버그가 발생 했습니까?

이미 코드를 작성했습니다. 문제는 UIAppearance가 맞춤 UINavigationBars 요소 때문에 앱을 다운시키고 있다는 것입니다. 코드.

-(void)message{ 
    if (_progressHUD){ 
     [_progressHUD hide:YES]; 
    } 
    MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init] ; 
    [controller setMessageComposeDelegate:self]; 

    if([MFMessageComposeViewController canSendText]) 
    { 
     controller.body = descriptionString; 
     controller.recipients = nil; 
     [self presentViewController:controller animated:YES completion:nil]; 
    } 

} 

-(void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result{ 
    [self dismissViewControllerAnimated:YES completion:nil]; 
} 

-(void)email { 

    if (_progressHUD){ 
     [_progressHUD hide:YES]; 
    } 

    MFMailComposeViewController *composer = [[MFMailComposeViewController alloc] init]; 
    [composer setMailComposeDelegate:self]; 
    if ([MFMailComposeViewController canSendMail]) { 
     [composer setToRecipients:nil]; 
     [composer setSubject:[NSString stringWithFormat:@"%@",nameString]]; 

     [composer setMessageBody:[NSString stringWithFormat:@"%@",descriptionString] isHTML:NO];  [composer addAttachmentData:[NSData dataWithContentsOfURL:[NSURL URLWithString:imageString]] mimeType:@"png" fileName:imageString]; 
     [composer setModalTransitionStyle:UIModalTransitionStyleCoverVertical]; 
     [self presentViewController:composer animated:YES completion:nil]; 
    } 
} 


-(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error { 
    if (error) { 
     SIAlertView *alert = [[SIAlertView alloc] initWithTitle:@"Error" 
                 andMessage:[NSString stringWithFormat:@"Error %@", [error description]]]; 
     [alert addButtonWithTitle:@"OK" type:SIAlertViewButtonTypeDestructive handler:^(SIAlertView *alertView){}]; 
     [alert show]; 
     [self dismissViewControllerAnimated:YES completion:nil]; 
    } 
    else { 
     [self dismissViewControllerAnimated:YES completion:nil]; 
    } 
} 

당신의하는 .m 파일에서 당신의 .H 파일에서 외관

- (void)customizeAppearance 
{ 
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; 

    UINavigationBar Appearance 
    [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"navigationBarBackground"] forBarMetrics:UIBarMetricsDefault]; 
    [[UINavigationBar appearance] setTintColor:[UIColor whiteColor]]; 
    [[UINavigationBar appearance] setTitleTextAttributes: 
    [NSDictionary dictionaryWithObjectsAndKeys: 
     [UIColor whiteColor], 
     UITextAttributeTextColor, 
     [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.0], 
     UITextAttributeTextShadowColor, 
     [NSValue valueWithUIOffset:UIOffsetMake(0, -1)], 
     UITextAttributeTextShadowOffset, 
     [UIFont fontWithName:@"HelveticaNeue" size:0.0], 
     UITextAttributeFont, 
     nil]]; 

    //ToolBar Appearance 
    [[UIToolbar appearance] setTintColor:[UIColor whiteColor]]; 


    //Switch Appearance 
    [[UISwitch appearance] setOnTintColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"greenBackground"]]]; 

    //Search Bar Appearance 
    [[UISearchBar appearance] setTintColor:[UIColor whiteColor]]; 

    //Tab Bar Appearance 
    [[UITabBar appearance] setBackgroundImage:[UIImage imageNamed:@"tabBarBackground"]]; 
    [[UITabBar appearance] setTintColor:[UIColor whiteColor]]; 
    [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], UITextAttributeTextColor, nil] forState:UIControlStateNormal]; 
    [[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageNamed:@"transparent"]]; 

} 
+0

이 시도 https://www.google.co.in/search?hl=en&noj=1&q=Assertion+failure+in+-[UICGColor+encodeWithCoder%3A]&oq=Assertion+failure+in+-[UICGColor+encodeWithCoder % 3A] & gs_l = serp.12 ... 5126.5126.0.6834.1.1.0.0.0.0.124.124.0j1.1.0 .... 0 ... 1c.1.26.serp..1.0.0.wx9jBNE9LbA – Spynet

+0

이미 시험해 보았습니다. 그것으로, 나는 구글을 사용할 수있다. 그러나 그것에서 어떤 수정도 찾지 못했다. – Phillip

답변

8

에 .H 파일

#import <MessageUI/MessageUI.h> 

@interface CustomController : UIViewController<MFMailComposeViewControllerDelegate> 

에서 프로젝트

MessageUI.framework 추가, I 그 충돌을 줄 수있는 코드 줄은

//Switch Appearance 
[[UISwitch appearance] setOnTintColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"greenBackground"]]]; 

그래서 삭제하고 모든 것이 잘 작동하고 있습니다. AppDelegate에서 직접 모양을 설정할 수는 없지만 스위치가있는 클래스에서이 작업을 수행해야했습니다.

tableController 모양과 동일한 사항 : tableView 클래스에서 설정해야합니다.

+1

Thx Pheel, 나는 당신의 답을 도우면서 내 문제의 해결책을 얻었습니다. :) – Nirmalsinh

+4

고마워요! 저에게 그것은'[UITableView appearance] setBackgroundColor : [UIColor colorWithPatternImage : someimage]];' –

+2

입니다. [UIColor colorWithPatternImage : image]와 연결되어있는 것 같습니다. 저에게 UIPageControl의 커스터마이징이었습니다. – Hugo

0

추가 위임<MFMessageComposeViewControllerDelegate,MFMailComposeViewControllerDelegate>

당신은 광고 할 필요가

-(void)ShareByEmail:(NSString *)strEmail { 
     MFMailComposeViewController *mail = [[MFMailComposeViewController alloc] init]; 
     mail.mailComposeDelegate = self; 
     if ([MFMailComposeViewController canSendMail]) { 

      NSString *bodyData = @"Boy data place here"; 


       NSString *strRecipients = [NSString stringWithFormat:@"%@",strEmail]; 
       strRecipients = [strRecipients stringByReplacingOccurrencesOfString:@"mailto:" withString:@""]; 
       NSArray * arrayRecipients = [strRecipients componentsSeparatedByString:@""]; 

       [mail setToRecipients:arrayRecipients]; 

      [mail setSubject:@"Subject"]; 
      [mail setMessageBody:bodyData isHTML:NO]; 
      [self presentViewController:mail animated:YES completion:nil]; 
     } 
     mail = nil; 
     return NSLog(@"%@",strEmail); 
    } 

-(void)shareBySMS:(NSString *)strSMS { 
    if([strSMS length] > 0) { 
      MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init]; 
      if(picker) { 
       picker.messageComposeDelegate = self; 

        picker.recipients = @"Youre Recipients"; 
        //picker.recipients = [NSArray arrayWithObject:tel]; 
        picker.body = strSMS; 

       [self presentViewController:picker animated:NO completion:nil]; 
       picker = nil; 
      } 
      NSLog(@"SMS fired"); 
     } 
} 


#pragma mark Mail Composer Delegate Methods 

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error { 

    // Notifies users about errors associated with the interface 
    switch (result) { 
     case MFMailComposeResultCancelled: 
      break; 
     case MFMailComposeResultSaved: 
      break; 
     case MFMailComposeResultSent: 
      break; 
     case MFMailComposeResultFailed: 
      break; 
     default: 
      break; 
    } 
    [self dismissViewControllerAnimated:YES completion:nil]; 
} 

    - (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result { 
     switch (result) { 
      case MessageComposeResultCancelled: 
       NSLog(@"Result: canceled"); 
       break; 
      case MessageComposeResultSent: 
       NSLog(@"Result: sent"); 
       break; 
      case MessageComposeResultFailed: 
       NSLog(@"Result: failed"); 
       break; 
      default: 
       NSLog(@"Result: not sent"); 
       break; 
     } 
     [self dismissViewControllerAnimated:YES completion:nil]; 
    } 
+0

이미이 코드가 있지만 어쨌든 충돌합니다. – Phillip

+0

여기에 코드를 추가 할 수 있습니까? –

+0

원래 질문을 편집했습니다. – Phillip

1

다음을 추가 트위터, 페이스 북에 필요한 프레임 워크. 이메일
가 다음을 수행하십시오

다양한 디버깅 세션 후, 해당하는 .m 파일

- (IBAction)actionEmail:(id)sender 
{ 
NSLog(@"actionEmail Called"); 

MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init]; 
mc.mailComposeDelegate = self; 
[self presentViewController:mc animated:YES completion:NULL]; 


} 

- (void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error 
{ 
switch (result) 
{ 
    case MFMailComposeResultCancelled: 
     NSLog(@"Mail cancelled"); 
     break; 
    case MFMailComposeResultSaved: 
     NSLog(@"Mail saved"); 
     break; 
    case MFMailComposeResultSent: 
     NSLog(@"Mail sent"); 
     break; 
    case MFMailComposeResultFailed: 
     NSLog(@"Mail sent failure: %@", [error localizedDescription]); 
     break; 
    default: 
     break; 
} 

// Close the Mail Interface 
[self dismissViewControllerAnimated:YES completion:NULL]; 
} 
+1

야, 난 이미 모든 코드, 필요한 프레임 워크와 모든 것들을 가지고있다.문제는 UIAppearance가 응용 프로그램 주변에 거의 적용 할 수있는 사용자 지정 UINavigationBar를 가지고 있기 때문에 충돌이 발생한다는 것입니다. – Phillip