1:Assertion failure in dequeueReusableCellWithIdentifier:forIndexPath:
static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
上面是在IOS9以下一直报闪退;后来改成下面解决:
static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell==nil) { cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; }
2:CoreTelephony框架不是私有库
私有框架的目录为:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/PrivateFrameworks/
可以看出CoreTelephony框架是在frameworks内而不是PrivateFrameworks,所以它是可以放心使用的。网上之所以有说CoreTelephony是私有库,是因为在iOS6的时候是私有框架,后来苹果又给公开了;
3:如何获取电话状态
a:首先要导入CoreTelephony框架:
@import CoreTelephony;
b:然后声明一个CTCallCenter变量:
@interface ViewController () { CTCallCenter *center_; //为了避免形成retain cycle而声明的一个变量,指向接收通话中心对象 } @end
然后监听电话状态:
- (void) aboutCall{ //获取电话接入信息 callCenter.callEventHandler = ^(CTCall *call){ if ([call.callState isEqualToString:CTCallStateDisconnected]){ NSLog(@"Call has been disconnected"); }else if ([call.callState isEqualToString:CTCallStateConnected]){ NSLog(@"Call has just been connected"); }else if([call.callState isEqualToString:CTCallStateIncoming]){ NSLog(@"Call is incoming"); }else if ([call.callState isEqualToString:CTCallStateDialing]){ NSLog(@"call is dialing"); }else{ NSLog(@"Nothing is done"); } }; }
还可以获取运营商信息:
- (void)getCarrierInfo{ // 获取运营商信息 CTTelephonyNetworkInfo *info = [[CTTelephonyNetworkInfo alloc] init]; CTCarrier *carrier = info.subscriberCellularProvider; NSLog(@"carrier:%@", [carrier description]); // 如果运营商变化将更新运营商输出 info.subscriberCellularProviderDidUpdateNotifier = ^(CTCarrier *carrier) { NSLog(@"carrier:%@", [carrier description]); }; // 输出手机的数据业务信息 NSLog(@"Radio Access Technology:%@", info.currentRadioAccessTechnology); }
当然这样在真机进行测试,以下为输出信息:
2015-12-29 16:34:14.525 RWBLEManagerDemo[1489:543655] carrier:CTCarrier (0x134e065c0) { Carrier name: [中国移动] Mobile Country Code: [460] Mobile Network Code:[07] ISO Country Code:[cn] Allows VOIP? [YES] } 2015-12-29 16:34:14.526 RWBLEManagerDemo[1489:543655] Radio Access Technology:CTRadioAccessTechnologyHSDPA
时间: 2024-10-10 15:05:16