我创建了一个使用 SMS 的应用程序,在用户单击 sms 按钮后,它会打开我的号码并且没有消息(这是他们的工作)。但是,当它加载 sms 消息页面时,它会设置光标所在的位置,而收件人不在消息所在的位置。为了更好地解释这一点,在短信加载后,如果他们只是开始输入,他们将添加另一个人来发送消息,而不是输入消息。例如,如果我想在启动时加载到 UIPicker 上的特定行,我会:
[picker selectRow:3 inComponent:0 animated:NO];
短信加载:
- (IBAction)sms {
MFMessageComposeViewController *textComposer = [[MFMessageComposeViewController alloc] init];
[textComposer setMessageComposeDelegate:self];
if ([MFMessageComposeViewController canSendText]) {
[textComposer setRecipients:[NSArray arrayWithObjects: @"support@nicmacengineering.com", nil]];
[textComposer setBody:@""];
[self presentViewController:textComposer animated:YES completion:NULL];
} else {
NSLog(@"Can't Open Text");
}
}
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
switch (result) {
case MessageComposeResultCancelled:
NSLog(@"Cancelled");
break;
case MessageComposeResultFailed:
break;
case MessageComposeResultSent:
break;
default:
break;
}
[self dismissViewControllerAnimated:YES completion:NULL];
}