Define actions When you click the Dial button
-(void) callaction{
NSString *number = @ "";//Here the phone number is read in
NSString *num = [[NSString alloc] initwithformat:@ "tel://%@", number]; Number is a string if you end the call using this method, the contact list is entered
NSString *num = [[NSString alloc] initwithformat:@ "telprompt://%@", number]; And this method is to call before the frame whether to call and then after the call back to the program online said this method may not be legal audit
[[UIApplication sharedapplication] Openurl:[nsurl Urlwithstring:num]]; Dial
}
The following code can add a phone button to the app and tap to call the phone number. It's also useful for iPhone developers.
Add Phone icon button
UIButton *btnphone = [[UIButton buttonwithtype:uibuttontyperoundedrect] retain];
Btnphone.frame = CGRectMake (280,10,30,30);
[Btnphone Setbackgroundcolor:[uicolor Redcolor];
Tap the Dial button to dial directly
[Btnphone addtarget:self Action: @selector (Callaction) forcontrolevents:uicontroleventtouchupinside];
[Self.window Addsubview:btnphone];
The third way to call
-(void) callphone{
NSString *phonenum = @ "";//Telephone number
Nsurl *phoneurl = [Nsurl urlwithstring:[nsstring stringwithformat:@ "tel:%@", Phonenum]];
if (!phonecallwebview) {
Phonecallwebview = [[UIWebView alloc] initwithframe:cgrectzero];//This webview is just a backstage easy no need to add to the page effect is the same as method two but this method is legal
}
[Phonecallwebview loadrequest:[nsurlrequest Requestwithurl:phoneurl];
}
iOS Call code