您可以使用以下代码实现:
NSUserDefaults *objUserDefaults = [NSUserDefaults standardUserDefaults];
NSString *savedPhone = [objUserDefaults objectForKey:@"savedPhone"];
[self callNumber:savedPhone];
然后添加以下函数:
-(void)callNumber:(NSString *)pstrContactNo
{
NSString *strDeviceModel = [UIDevice currentDevice].model;
if(![strDeviceModel isEqualToString:@"iPhone"])
{
UIAlertView *objAlertMsg = [[UIAlertView alloc] initWithTitle:@""
message:@"Calling is not supported in this device."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[objAlertMsg show];
[objAlertMsg release];
}
else
{
pstrContactNo = [NSString stringWithFormat:@"tel:%@",pstrContactNo];
NSString *strDialedContact = [pstrContactNo stringByReplacingOccurrencesOfString:@" " withString:@""];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:strDialedContact]];
}
}
这将解决您的问题。
干杯!