Write in the appropriate code:
1. Call Telephone Phone
[[UIApplication sharedapplication]openurl:[nsurl urlwithstring:@ "tel://4008008288"];
2. Call your own browser safari
[[UIApplication sharedapplication] openurl:[nsurlurlwithstring:@ "http://www.abt.com"];
3. Call to bring your own mail
[[UIApplication sharedapplication] openurl:[nsurlurlwithstring:@ "Mailto://[email protected]"];
4. Call SMS
[[UIApplication sharedapplication] openurl:[nsurlurlwithstring:@ "sms://800888"];
5, jump to system settings related interface
[[Uiapplicationsharedapplication] Openurl:[nsurl urlwithstring:@ "Prefs:root=wifi"];
Among them, the function of sending text messages, emailing can only fill in the address or number to send, unable to initialize the sending content, if you want to implement the content, but also need more complex, to implement their respective delegation method.
If you need to pass content, you can do the following:
Join: Messageui.framework
#import <MessageUI/MFMessageComposeViewController.h>
Implement Proxy: Mfmessagecomposeviewcontrollerdelegate
Call the Sendsms function
Content, recipient list
-(void) Sendsms: (NSString *) bodyofmessage recipientlist: (Nsarray *) recipients
{
Mfmessagecomposeviewcontroller *controller = [[[[Mfmessagecomposeviewcontroller alloc] init] autorelease];
if ([Mfmessagecomposeviewcontroller Cansendtext])
{
Controller.body = Bodyofmessage;
controller.recipients = Recipients;
Controller.messagecomposedelegate = self;
[Self Presentmodalviewcontroller:controller animated:yes];
}
}
Processing the results of a response sent out
-(void) Messagecomposeviewcontroller: (Mfmessagecomposeviewcontroller *) controller didfinishwithresult: ( Messagecomposeresult) Result
{
[Self dismissmodalviewcontrolleranimated:yes];
if (Result = = messagecomposeresultcancelled)
NSLog (@ "Message cancelled")
Else if (Result = = Messagecomposeresultsent)
NSLog (@ "Message sent")
Else
NSLog (@ "Message failed")
}
The message is sent as:
Importing # import <MessageUI/MFMailComposeViewController.h>
Implement Proxy: Mfmailcomposeviewcontrollerdelegate
Send mail
-(void) SendMail: (NSString *) Subject content: (NSString *) content{
Mfmailcomposeviewcontroller *controller = [[[[Mfmailcomposeviewcontroller alloc] init] autorelease]; if ([Mfmailcomposeviewcontroller Cansendmail])
{
[Controller Setsubject:subject];
[Controller setmessagebody:content Ishtml:no];
Controller.mailcomposedelegate = self;
[Self Presentmodalviewcontroller:controller animated:yes];
}
}
Message completion Processing
-(void) Mailcomposecontroller: (Mfmailcomposeviewcontroller *) controller didfinishwithresult: ( Mfmailcomposeresult) Result Error: (Nserror *) error{
[Self dismissmodalviewcontrolleranimated:yes];
if (Result = = messagecomposeresultcancelled)
NSLog (@ "Message cancelled");
Else if (Result = = Messagecomposeresultsent)
NSLog (@ "Message sent");
Else NSLog (@ "Message failed");
}
The default text messaging interface is in English, the solution is: Add a group of localization in the. Xib Chinese
How does the code implement jump Safari,phone or message?