1:afnetwork Determine network status
#import "AFNetworkActivityIndicatorManager.h"-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchoptions {//Network[[Afnetworkactivityindicatormanager Sharedmanager] setenabled:yes]; [[Afnetworkreachabilitymanager Sharedmanager] startmonitoring]; //Network State judgment[[Afnetworkreachabilitymanager Sharedmanager] setreachabilitystatuschangeblock:^(afnetworkreachabilitystatus status) {Switch(status) { Caseafnetworkreachabilitystatusnotreachable:{[self showmbphudtipstr:@"No network connection currently"]; Break; } Caseafnetworkreachabilitystatusreachableviawifi:{[logutil logutilstring:@"WiFi internet"]; Break; } Caseafnetworkreachabilitystatusreachableviawwan:{[self showmbphudtipstr:@"Wireless Network"]; Break; } default: Break; } }]; returnYES;}
2:uibutton Countdown
when the countdown UIButton cannot be responded to events;-(void) starttime{__blockinttimeout= -;//Countdown Timedispatch_queue_t queue = Dispatch_get_global_queue (Dispatch_queue_priority_default,0); dispatch_source_t _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, ^{ if(timeout<=0){//countdown end, closeDispatch_source_cancel (_timer); Dispatch_async (Dispatch_get_main_queue (),^{ //set the interface button to display the settings according to your needs[Self.againbtn Settitle:@"re-send verification code"Forstate:uicontrolstatenormal]; Self.againBtn.userInteractionEnabled=YES; Self.labNoMessage.text=@"didn't receive the verification code? "; Self.labNoMessage.textColor=[Uicolor Redcolor]; }); }Else{ intseconds = Timeout% -; NSString*strtime = [NSString stringWithFormat:@"%.2d", seconds]; Dispatch_async (Dispatch_get_main_queue (),^{ //set the interface button to display the settings according to your needs[Self.againbtn settitle:[nsstring stringWithFormat:@"re-send activation email (%@)", Strtime] forstate:uicontrolstatenormal]; Self.againBtn.userInteractionEnabled=NO; Self.labNoMessage.text=@"activation message sent successfully"; Self.labNoMessage.textColor=[uicolor colorwithhexstring:@"84bf20"]; }); Timeout--; } }); Dispatch_resume (_timer); }
3: Judging iphone devices
#defineIs_ipad (ui_user_interface_idiom () = = Uiuserinterfaceidiompad)#defineIs_iphone (ui_user_interface_idiom () = = Uiuserinterfaceidiomphone)#defineIs_retina ([[UIScreen mainscreen] scale] >= 2.0)#defineScreen_width ([[UIScreen mainscreen] bounds].size.width)#defineScreen_height ([[UIScreen mainscreen] bounds].size.height)#defineScreen_max_length (MAX (Screen_width, Screen_height))#defineScreen_min_length (MIN (Screen_width, Screen_height))#defineIs_iphone_4_or_less (Is_iphone && screen_max_length < 568.0)#defineIs_iphone_5 (is_iphone && screen_max_length = = 568.0)#defineIs_iphone_6 (is_iphone && screen_max_length = = 667.0)#defineis_iphone_6p (is_iphone && screen_max_length = = 736.0)
4: Report an automatic layout bug in IOS8, while IOS8 can run normally
-layoutsubviews.
UITableView ' s implementation of-Layoutsubviews needs to call super. ' -(void) layoutsubviews{ // Auto-layout content in front of Super Layoutsubviews [Self _ Updateconstraints]; [Super Layoutsubviews];}
5: Interaction with JS, and the JS code compatible with Android and iOS
JS Code: $ (function () {varU = navigator.useragent, app =navigator.appversion; varIsandroid = U.indexof ('Android') >-1|| U.indexof ('Linux') >-1;//Android Terminal or UC browser varIsios =!! U.match (/\ (i[^;] +;( U;)? Cpu.+mac OS x/);//iOS terminal if(isandroid) {$ ('#btn_Success'). attr ('href','javascript:mailActive.backHome ()'); } Else if(Isios) {$ ('#btn_Success'). attr ('href','Protoclo://backhome'); }), while iOS is shouldstartloadwithrequest:-(BOOL) WebView: (UIWebView *) WebView shouldstartloadwithrequest: (Nsurlrequest *Request Navigationtype: (uiwebviewnavigationtype) navigationtype{nsstring*newurl=[[Request URL] absolutestring]; if([Newurl Hasprefix:@"protoclo://"]) {Nsarray*stringarray=[newurl componentsseparatedbystring:@"//"]; if(stringarray.count>1&&[[stringarray Objectatindex:1] Isequaltostring:@"Backhome"]) {[Self webjavascriptbackhome]; } } returnYES;} Note: Better iOS JS interactive third-party plug-in Webviewjavascriptbridge, iOS development debugging embedded WebView can be debugged with Safari, it can set the development Mode menu, development->ios Simulator can be used to view the running details of the webpage (safari-> Preferences-advanced-show "development" in the menu);
iOS Development Basics-Fragmentation 11