IOS開發基礎知識--片段48,ios基礎知識--48

來源:互聯網
上載者:User

IOS開發基礎知識--片段48,ios基礎知識--48

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

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.