UIApperance and various crashes

后端 未结 3 1890
庸人自扰
庸人自扰 2021-01-07 01:09

I\'m getting so frustrated while customizing my app. I\'ve already created and styled almost the whole app, including Navigation bar, toolbar, tabBar etc, but everytime a MF

3条回答
  •  滥情空心
    2021-01-07 01:51

    In your .h file add delegate

    In your .m file add following

     -(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];
        }
    

提交回复
热议问题