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