如果你想準確地更新它每隔幾個seconds.here
-(void)UpdateLabelWithSignal{
int str = CTGetSignalStrength();
NSLog(@"SignalStrength:%d",str);
NSLog(@"SignalStrength:%@",[NSString stringWithFormat:@"%d",str]);
SignalLabel.text = [NSString stringWithFormat:@"%d",str];
}
//代碼的代碼。
- (void)viewDidLoad
{
[super viewDidLoad];
printf("signal strength: %d\n", CTGetSignalStrength());
slimeDeathAnimTimer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(UpdateLabelWithSignal) userInfo:nil repeats:YES];
CTTelephonyNetworkInfo *netinfo = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier *carrier = [netinfo subscriberCellularProvider];
NSLog(@"MY NAME:%@",carrier.carrierName);
NSLog(@"mobileCountryCode = %@",carrier.mobileCountryCode);
NSLog(@"mobileNetworkCode = %@",carrier.mobileNetworkCode);
NSLog(@"isoCountryCode = %@",carrier.isoCountryCode);
NSLog(@"allowVOIP = %d",carrier.allowsVOIP);
}
-(void)UpdateLabelWithSignal{
int str = CTGetSignalStrength();
NSLog(@"SignalStrength:%d",str);
NSLog(@"SignalStrength:%@",[NSString stringWithFormat:@"%d",str]);
SignalLabel.text = [NSString stringWithFormat:@"%d",str];
}
的可能重複:http://stackoverflow.com/questions/15427507/how-to-find-out-carrier-signal-strength-programatically?rq=1 –
我din't明白 – user2402997
這是[this]可能的重複(http://stackoverflow.com/questions/8254327/get-carrier-name-and-signal-strength-return-wrong-value-in-iphone)和[this](http:這個問題可以通過下面的代碼來解決:(http://stackoverflow.com/questions/15427507/how-to -find-out-carrier-signal-strength-programatically/15531806#15531806)你的解決方案鏈接 –