Sms 在iOS 7中发送短信它不工作
} } 当我单击按钮1时,它不工作,并且没有arlet错误 但当点击下面的按钮时,它在iOS 7上正常工作,但我无法分配消息内容。 请指导我如何将消息内容分配给此按钮编号2Sms 在iOS 7中发送短信它不工作,sms,send,Sms,Send,} } 当我单击按钮1时,它不工作,并且没有arlet错误 但当点击下面的按钮时,它在iOS 7上正常工作,但我无法分配消息内容。 请指导我如何将消息内容分配给此按钮编号2 - (IBAction)button_number1:(id)sender { MFMessageComposeViewController *textComposer = [[MFMessageComposeViewController alloc] init]; [textComposer setMessageCo
- (IBAction)button_number1:(id)sender {
MFMessageComposeViewController *textComposer = [[MFMessageComposeViewController alloc] init];
[textComposer setMessageComposeDelegate:self];
if ([MFMessageComposeViewController canSendText]) {
[textComposer setRecipients:@[string_numberphone]];
[textComposer setBody:@"ABC"];
[self presentViewController:textComposer animated:YES completion:NULL];
} else {
NSLog(@"Can't Open Text");
}
}
非常感谢 in.h头文件
- (IBAction)button_number2:(id)sender {
NSString *message = [[NSString alloc] initWithFormat:@"sms:%@",string_numberphone];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:message ]];
#import <MessageUI/MessageUI.h>
@interface MainViewController : UIViewController <MFMessageComposeViewControllerDelegate>{
- (IBAction)sendsms:(id)sender;
}
- (IBAction)showEmail:(id)sender{
if (phoneNumber!=NULL) {
UIDevice *device = [UIDevice currentDevice];
if ([[device model] isEqualToString:@"iPhone"] ) {
NSString *phNo = [phoneNumber stringByReplacingOccurrencesOfString:@" " withString:@""];
NSURL *phoneUrl = [NSURL URLWithString:[NSString stringWithFormat:@"telprompt:%@",phNo]];
if ([[UIApplication sharedApplication] canOpenURL:phoneUrl]) {
[[UIApplication sharedApplication] openURL:phoneUrl];
} else
{
UIAlertView *calert = [[UIAlertView alloc]initWithTitle:@"Alert" message:@"Call facility is not available!!!" delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil, nil];
[calert show];
[calert release];
}
} else {
UIAlertView *warning =[[UIAlertView alloc] initWithTitle:@"Alert" message:@"Your device doesn't support this feature." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[warning show];
[warning release];
}
}
else {
UIAlertView *warning =[[UIAlertView alloc] initWithTitle:@"Alert" message:@"Phone No is not Available." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[warning show];
[warning release];
}
}