Let's start by introducing one of the simplest methods:
Call Call function
[[Uiapplicationsharedapplication] Openurl:[nsurl urlwithstring:@ "tel://10086"];
Call to send SMS function
[[UIApplication Sharedapplication]openurl:[nsurl urlwithstring:@ "sms://10000"]];
The above text messaging function is to call the system interface, the following is a click to implement a button to send text messages directly, equivalent to send the background, can be on the software store, not sure. Relative recommendations, try to use the first one.
First import mfmessagecomposeviewcontrollerdelegate This agent, implement the method inside
-(void) Messagecomposeviewcontroller: (mfmessagecomposeviewcontroller *) Controllerdidfinishwithresult: (messagecomposeresult) Result {
//notifies users about errors associated with the interface
Switch (Result) {
Case messagecomposeresultcancelled:
if (DEBUG) NSLog (@ "result:canceled");
break;
Case messagecomposeresultsent:
if (DEBUG) NSLog (@ "result:sent");
break;
Case messagecomposeresultfailed:
if (DEBUG) NSLog (@ "result:failed");
break;
default:
break;
}
[ self dismissmodalviewcontrolleranimated:YES];
}
Mass SMS:
-(ibaction) sendsms {
BOOL cansendsms = [mfmessagecomposeviewcontrollercansendtext];
NSLog (@ "can send SMS [%d]", cansendsms);
if (cansendsms) {
mfmessagecomposeviewcontroller *picker = [[mfmessagecomposeviewcontrolleralloc] Init];
Picker. messagecomposedelegate =self;
Picker. Navigationbar. Tintcolor = [uicolorblackcolor];
Picker. Body = @ "Test";
Picker. Recipients = [nsarrayarraywithobject:@ "10086"];
[ self presentmodalviewcontroller:p icker animated:YES];
[Picker release];
}
}
Send a text message to a person:
Get content from a Web page
-(void) Displaysmscomposersheet
{
mfmessagecomposeviewcontroller *picker = [[mfmessagecomposeviewcontrolleralloc] Init];
Picker. messagecomposedelegate =self;
UIWebView *web = nil;
nsmutablestring* Absurl = [[nsmutablestringalloc] initwithstring: Web. Request. URL. absolutestring];
[Absurl replaceoccurrencesofstring:@ "http://i.aizheke.com"withstring:@ "/http/ M.aizheke.com "options:nscaseinsensitivesearchrange:nsmakerange (0, [absurllength])];
Picker. body=[nsstringstringwithformat:@ " I see in the Love fold:%@ may be useful to you, Recommend to you! link:%@ ", [webstringbyevaluatingjavascriptfromstring:@" Document.title " ],absurl];
[Absurl release];
[ self presentmodalviewcontroller:p icker animated:YES];
[Picker release];
}
Event binding Send SMS
-(ibaction) Showsmspicker: (ID) Sender {
Class MessageClass = (nsclassfromstring(@ "Mfmessagecomposeviewcontroller"));
if (MessageClass! = Nil) {
if ([MessageClass cansendtext]) {
[ self displaysmscomposersheet];
}
Else {
// device does not have SMS function
}
}
Else {
//IOS version too low , iOS4.0 above to support sending SMS within the program
}
}
iOS SMS Feature