Basic knowledge of IOS development-fragmentation 48, basic knowledge of ios-48

Source: Internet
Author: User

Basic knowledge of IOS development-fragmentation 48, basic knowledge of ios-48

1: Assertion failure in dequeueReusableCellWithIdentifier: forIndexPath:

static NSString *CellIdentifier = @"Cell";UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier                                      forIndexPath:indexPath];

The above is always reported as a crash under IOS9; then changed to the following solution:

static NSString *CellIdentifier = @"Cell";    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];   if (cell==nil) {      cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];    }

2: CoreTelephony framework is not a private library

The Directory of the private framework is:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/PrivateFrameworks/

It can be seen that the CoreTelephony framework is in frameworks rather than PrivateFrameworks, so it can be safely used. The reason why CoreTelephony is a private library on the internet is that it was a private framework in iOS6, And then Apple made it public again;

3: how to get the phone status

A: First, import the CoreTelephony framework:

@ Import CoreTelephony;

B: Then declare a CTCallCenter variable:

@ Interface ViewController () {CTCallCenter * center _; // a variable declared to avoid retain cycle, pointing to the recipient's call center object} @ end

Then listen to the phone status:

-(Void) aboutCall {// obtain call access information callCenter. callEventHandler = ^ (CTCall * call) {if ([call. callState islog tostring: 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 ");}};}

You can also obtain carrier information:

-(Void) getCarrierInfo {// obtain carrier information CTTelephonyNetworkInfo * info = [CTTelephonyNetworkInfo alloc] init]; CTCarrier * carrier = info. subscriberCellularProvider; NSLog (@ "carrier: % @", [carrier description]); // if the carrier changes, the carrier will be updated to output info. subscriberCellularProviderDidUpdateNotifier = ^ (CTCarrier * carrier) {NSLog (@ "carrier: % @", [carrier description]);}; // output NSLog (@ "Radio Access Technology: % @", info. currentRadioAccessTechnology );}

Of course, the test is conducted on the real machine. The output information is as follows:

16:34:14. 525 RWBLEManagerDemo [1489: 543655] carrier: CTCarrier (0x134e065c0) {Carrier name: [China Mobile] Mobile Country Code: [460] Mobile Network Code: [07] ISO Country Code: [cn] Allows VOIP? [YES]} 16:34:14. 526 RWBLEManagerDemo [1489: 543655] Radio Access Technology: CTRadioAccessTechnologyHSDPA

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.