IOS模拟器能获取运营商信息,网络连接类型以及地理位置吗?
2016-12-30 00:47
507 查看
代码如下:
//获取运营商信息和网络连接类型
-(void)getCarrierInfoAndConnectType
{
CTTelephonyNetworkInfo* info = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier* carrier = [info subscriberCellularProvider];
if (carrier != NULL)
{
mCarrier = [carrier carrierName];
mConnectType = [carrier mobileNetworkCode];
}
NSLog(@"carrier:%@",mCarrier);
NSLog(@"connectype:%@",mConnectType);
}
//获取地理位置
- (void) getPosInfo
{
CLLocationManager* locationManager = [[CLLocationManager alloc] init];
if(![locationManager locationServicesEnabled])
{
NSLog(@"请打开定位服务");
return ;
}
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
locationManager.distanceFilter = kCLDistanceFilterNone;
[locationManager startUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
NSLog(@"获取地理位置开始");
CLLocation* currentLocation = [locations lastObject];
CLLocationCoordinate2D coor = currentLocation.coordinate;
mUserPos =[[NSString alloc] initWithFormat:@"latitude=%g&longitude=%g",coor.latitude,coor.longitude];
NSLog(@"userpos:%@",mUserPos);
}
//******************
上述代码得到的运营商信息,网络连接类型,地理位置都是空,要怎么获取?
//获取运营商信息和网络连接类型
-(void)getCarrierInfoAndConnectType
{
CTTelephonyNetworkInfo* info = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier* carrier = [info subscriberCellularProvider];
if (carrier != NULL)
{
mCarrier = [carrier carrierName];
mConnectType = [carrier mobileNetworkCode];
}
NSLog(@"carrier:%@",mCarrier);
NSLog(@"connectype:%@",mConnectType);
}
//获取地理位置
- (void) getPosInfo
{
CLLocationManager* locationManager = [[CLLocationManager alloc] init];
if(![locationManager locationServicesEnabled])
{
NSLog(@"请打开定位服务");
return ;
}
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
locationManager.distanceFilter = kCLDistanceFilterNone;
[locationManager startUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
NSLog(@"获取地理位置开始");
CLLocation* currentLocation = [locations lastObject];
CLLocationCoordinate2D coor = currentLocation.coordinate;
mUserPos =[[NSString alloc] initWithFormat:@"latitude=%g&longitude=%g",coor.latitude,coor.longitude];
NSLog(@"userpos:%@",mUserPos);
}
//******************
上述代码得到的运营商信息,网络连接类型,地理位置都是空,要怎么获取?
相关文章推荐
- IOS模拟器能获取运营商信息,网络连接类型以及地理位置吗?
- iOS利用CoreLocation获取地理位置以及如何在模拟器进行调试
- iOS 关于获取网络类型和运营商信息
- iOS状态栏获取网络类型,运营商,电池电量,显示的系统时间等信息
- iOS获取当前设备的型号、分辨率、运营商以及地理位置
- iOS:关于获取网络类型和运营商信息
- iOS:关于获取网络类型和运营商信息
- iOS:关于获取网络类型和运营商信息
- iOS获取网络类型和运营商信息
- iOS利用CoreLocation获取地理位置以及如何在模拟器进行调试
- iOS:关于获取网络类型和运营商信息
- iOS状态栏获取网络类型,运营商,电池电量,显示的系统时间等信息
- iOS:关于获取网络类型和运营商信息
- iOS利用CoreLocation获取地理位置以及如何在模拟器进行调试
- iOS利用CoreLocation获取地理位置以及如何在模拟器进行调试
- ios获取地理位置信息
- iOS-获取当前设备的信息,网络状态,运营商,设备震动.获取设备信息
- iOS CoreLocation框架第三章—— CLGeocoder(地理编码器)和CLPlacemark(获取位置信息)
- ios 定位经纬度获取位置信息,地理位置编码与反编码
- iOS中利用系统地图获取定位信息(经纬度/地理位置)