简体   繁体   English

如何使用iPhone SDK检测设备是否没有SIM卡?

[英]How do I detect if device doesn't have a sim card using iphone sdk?

i am using these methods to get my location.all works fine in simulator.but on real device it runs very fast.how do i slow this down,also how do i show error only once if the device have not sim inserted and also for user denied to use current location. 我正在使用这些方法来获取我的位置。在模拟器上一切正常。但是在真实设备上它运行得非常快。我如何减慢它的速度,如果设备未插入sim卡,并且我也只显示一次错误?用户被拒绝使用当前位置。 here are the methods-- 这里是方法-

-(void)GetCurrentLocation {
 // Create the location manager if this object does not
 // already have one.
 if (nil == locationManager)
  locationManager = [[CLLocationManager alloc] init]; 
 if (locationManager.locationServicesEnabled == NO) {
    UIAlertView *servicesDisabledAlert = [[UIAlertView alloc] initWithTitle:@"Location Services Disabled" message:@"You currently have all location services for this device disabled. If you proceed, you will be asked to confirm whether location services should be reenabled." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [servicesDisabledAlert show];
    [servicesDisabledAlert release];
 [locationManager release];
    }       
else{
  locationManager.delegate = self;
  locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters; 
  [btnGPSFix setHidden:NO];
  [UIView beginAnimations:nil context:nil];
  [UIView setAnimationDuration:1.0];// Sub. duration  
  [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:btnGPSFix cache:YES];
  [self showMsg:@"Getting a GPS fix..." WithDelay:7];
  [UIView commitAnimations];
  [locationManager startUpdatingLocation];
 }
}

// Delegate method from the CLLocationManagerDelegate protocol. //从CLLocationManagerDelegate协议委托方法。

  - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
 // If it's a relatively recent event, turn off updates to save power
 NSDate* eventDate = newLocation.timestamp;
  NSTimeInterval howRecent = [eventDate timeIntervalSinceNow];
 if (abs(howRecent) < 5.0) {
  [manager stopUpdatingLocation];  
  printf("latitude %+.6f, longitude %+.6f\n",newLocation.coordinate.latitude,newLocation.coordinate.longitude);
  LatitudeData = [[NSString alloc] initWithFormat:@"%f",newLocation.coordinate.latitude];
  LongitudeData = [[NSString alloc] initWithFormat:@"%f",newLocation.coordinate.longitude];
 [UIView beginAnimations:nil context:nil];
 [UIView setAnimationDuration:1.0];// Sub. duration  
 [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:btnGPSFix cache:YES];
  [self showMsg:@"GPS Acquired" WithDelay:4];
  [UIView commitAnimations];
  [self insertIntoDataBase];
  }
  // else skip the event and process the next one.
 }

here is my [self showMsg: WithDelay:] Method 这是我的[self showMsg:WithDelay:]方法

 - (void)showMsg:(NSString*)Message WithDelay:(int)delay
 {
 CGRect frame = CGRectMake(30, 366, 259, 37);
 [btnGPSFix setTitle:Message forState:UIControlStateNormal];
 [UIView beginAnimations:nil context:NULL];
 [UIView setAnimationDuration:1.0]; 
 frame.origin.y = 366;
 btnGPSFix.frame = frame; 
 [UIView commitAnimations]; 
 // Hide the view after the requested delay
 [self performSelector:@selector(HideGpsFixButton) withObject:nil afterDelay:delay]; 
}

Here is the HideGpsFixButton Method 这是HideGpsFixButton方法

- (void)HideGpsFixButton
{
 // Slide the view down off screen
 CGRect frame = CGRectMake(30, 366, 259, 37); 
 [UIView beginAnimations:nil context:NULL];
 [UIView setAnimationDuration:1.0];
 frame.origin.y = 480;
 btnGPSFix.frame = frame; 
 [UIView commitAnimations];

}

i have checked in device it shows getting a gps fix message.device doesn't have sim inserted.i want to show only one message that your device doesn't have sim inserted or if user disallow location service then show the message location service is disabled by the user.any help appreciated. 我已签入设备,它显示收到gps修复消息。设备未插入sim卡。我只想显示一条消息,表明您的设备未插入sim卡,或者如果用户不允许定位服务,则显示消息定位服务为用户禁用。感谢任何帮助。

您不能,Apple不会公开任何有关SIM卡,手机无线电,所用网络等信息的信息。如果您需要此功能,则应向Apple 提交错误说明原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM