当前位置: 代码迷 >> Iphone >> 拨通电话的封装。和判断是否为iphone5的封装
  详细解决方案

拨通电话的封装。和判断是否为iphone5的封装

热度:84   发布时间:2016-04-25 06:03:31.0
拨打电话的封装。和判断是否为iphone5的封装

+(void)telViewController:(id)viewController telNum:(NSString *)telNum{
??? NSString *deviceType = [UIDevice currentDevice].model;
??? if([deviceType? isEqualToString:@"iPod touch"]||[deviceType? isEqualToString:@"iPad"]||[deviceType? isEqualToString:@"iPhone Simulator"]){
??????? UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"提示" message:@"您的设备不能打电话" delegate:nil cancelButtonTitle:@"好的,知道了" otherButtonTitles:nil,nil];
??????? [alert show];
??????? [alert release];
??????? return;
??? }
??? UIActionSheet *actionSheet = [[UIActionSheet alloc]initWithTitle:nil delegate:(id)[ViewControllerFactory sharedManager] cancelButtonTitle:@"取消" destructiveButtonTitle:telNum otherButtonTitles:nil, nil];
??? UIViewController *tempViewController = (id)viewController;
??? [actionSheet showInView:tempViewController.view];
??? [actionSheet release];
}
#pragma mark ====== 是否取消或者继续拨打电话 ======
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
??? NSString *telString = [actionSheet buttonTitleAtIndex:buttonIndex];
??? NSLog(@"buttonTitle===%@",[actionSheet buttonTitleAtIndex:buttonIndex]);
??? NSLog(@"%d",buttonIndex);
??? if (buttonIndex==0) {
??????? [[UIApplication sharedApplication] openURL:[NSURL URLWithString:telString]];
??? }
}




static ViewControllerFactory *classA = nil;//静态的该类的实例
+ (ViewControllerFactory *)sharedManager
{
@synchronized(self) {
??? if (!classA) {
??????? classA = [[super allocWithZone:NULL]init];
??? }
??? return classA;
}
}
+ (id)allocWithZone:(NSZone *)zone {
??? return [[self sharedManager] retain];
}
- (id)copyWithZone:(NSZone *)zone {
??? return self;
}
- (id)retain {
??? return self;
}
//- (NSUIntger)retainCount {
//??? return NSUIntgerMax;
//}
- (oneway void)release {
}
- (id)autorelease {
??? return self;
}
-(void)dealloc{
}

?

?

?

?

?

+(id)createViewControllerByControllerName:(NSString*) controllerName {
??? if (controllerName == nil || [controllerName isEqualToString:@""]) {
??????? return nil;
??? }
??? NSString *controllerXibName = nil;
??? if (isIPhone5) {
??????? controllerXibName = [NSString stringWithFormat:@"%@_iphone5",controllerName];
??? }else {
??????? controllerXibName = controllerName;
??? }
??? Class class = NSClassFromString(controllerName);
?? return? [[[class alloc] initWithNibName:controllerXibName bundle:nil] autorelease];
}