iOS Knowledge points Summary

Source: Internet
Author: User

1. Monitor network status:

- (void) checknetwork {__block NSString*tips; _reachiabilitymanager=[Afnetworkreachabilitymanager Manager]; [_reachiabilitymanager Setreachabilitystatuschangeblock:^(afnetworkreachabilitystatus status) {Switch(status) { Case-1: {Tips=@"Unknown network error";  Break; }             Case 0: {Tips=@"No network, please check the network";  Break; }             Case 1: {Tips=@"data traffic for the current connection";  Break; }             Case 2: {Tips=@"Wi-Fi is currently connected";  Break; }            default:                 Break; }        if(tips.length) {//Tips        }    }]; [_reachiabilitymanager startmonitoring];}

2. Enter the live page to determine the permissions:

//determine if it is an emulator        if([[[Uidevice Currentdevice] issimulator]) {[Self shownoticemessage:@"please run with the real machine"]; returnNO; }                //determine if there is a camera        if(![Uiimagepickercontroller Issourcetypeavailable:uiimagepickercontrollersourcetypecamera]) {[Self shownoticemessage:@"your device does not have a webcam or related driver and cannot be streamed"]; returnNO; }                //determine if camera permissions are availableAvauthorizationstatus Authorizationstatus =[Avcapturedevice Authorizationstatusformediatype:avmediatypevideo]; if(Authorizationstatus = = avauthorizationstatusrestricted| | authorizationstatus = =avauthorizationstatusdenied) {[Self shownoticemessage:@"the app needs to access your webcam. \ n Please enable webcam-settings/privacy/webcam"]; returnNO; }                //Turn on Microphone permissionsAvaudiosession *audiosession =[Avaudiosession sharedinstance]; if([audiosession respondstoselector: @selector (requestrecordpermission:)]) {[Audiosession performselector:@s Elector (requestrecordpermission:) Withobject:^(BOOL granted) {if(granted) {returnYES; } Else{[Self shownoticemessage:@"the app needs to access your microphone. \ n Please enable microphone-settings/privacy/Microphone"]; returnNO;        }            }]; }

3. Third parties for live use:

Video playback: ijkmediaframework

Barrage: Barragerenderer

Push Flow: Lflivekit

SOURCE Learning: Https://github.com/SunLiner/MiaowShow

Countdown in 4.Cell:

///Execute once per second- (void) Countdownwithper_secblock: (void(^) ()) Per_secblock {if(_timer==Nil) {dispatch_queue_t Queue= Dispatch_get_global_queue (Dispatch_queue_priority_default,0); _timer= Dispatch_source_create (Dispatch_source_type_timer,0,0, queue); Dispatch_source_set_timer (_timer,dispatch_walltime (NULL,0),1.0*nsec_per_sec,0);//executes per secondDispatch_source_set_event_handler (_timer, ^{Dispatch_async (Dispatch_get_main_queue (),^{per_secblock ();        });        });    Dispatch_resume (_timer); }}

5. Set "Search highlighting" when searching:

 //  set search highlighting   If  (Model.searchKeyWord.length > 0  //  Find special text from all text  Nsrange range = [Model.titlestr RangeOfString:model.searchKeyWord];  if  (range.location! = Nsnotfound && range.length > 0  ) {nsmutableattributedstring  *muattstr = [[Nsmutableattributedstring alloc] initWithString:model.titleStr];            [Muattstr addattribute:nsforegroundcolorattributename Value:blue_color Range:range];        Self.titleLabel.attributedText  = Muattstr; }            }

iOS Knowledge points Summary

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.