1:afnetwork Determine network status
#import "AFNetworkActivityIndicatorManager.h"-(BOOL) Application: (UIApplication *) application Didfinishlaunchingwithoptions: (nsdictionary *) launchoptions {//network [[Afnetworkactivityindicatormanager SharedManage R] Setenabled:yes]; [[Afnetworkreachabilitymanager Sharedmanager] startmonitoring]; Network state judgment [[Afnetworkreachabilitymanager Sharedmanager] setreachabilitystatuschangeblock:^ ( Afnetworkreachabilitystatus status) {switch (status) {case afnetworkreachabilitystatusnotreachable:{ [Self showmbphudtipstr:@ "currently no network Connection"]; Break } case afnetworkreachabilitystatusreachableviawifi:{[logutil logutilstring:@ "WiFi network"]; Break } case afnetworkreachabilitystatusreachableviawwan:{[self showmbphudtipstr:@ "wireless network"]; Break } Default:break; } }]; return YES;}
2:uibutton Countdown
When the countdown UIButton cannot be responded to the event;-(void) starttime{__block int timeout=60;//countdown time dispatch_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); Execute Dispatch_source_set_event_handler per second (_timer, ^{if (timeout<=0) {//Countdown end, close Dispatch_source_can Cel (_timer); Dispatch_async (Dispatch_get_main_queue (), ^{//SET interface button display according to your own needs settings [Self.againbtn settitle:@ " Re-send verification code "Forstate:uicontrolstatenormal"; self.againBtn.userInteractionEnabled = YES; [Email protected] "Did you receive the verification code? "; Self.labnomessage.textcolor=[uicolor Redcolor]; }); }else{int seconds = timeout% 60; NSString *strtime = [NSString stringwithformat:@ "%.2d", seconds]; Dispatch_async (DispatCh_get_main_queue (), ^{//SET interface button display according to your own needs settings [self.againbtn settitle:[nsstring stringwithfor mat:@ "re-send activation mail (%@)", Strtime] forstate:uicontrolstatenormal]; self.againBtn.userInteractionEnabled = NO; [email protected] "activation message sent successfully"; Self.labnomessage.textcolor=[uicolor colorwithhexstring:@ "84bf20"]; }); timeout--; } }); Dispatch_resume (_timer); }
3: Judging iphone devices
#define IS_IPAD (ui_user_interface_idiom () = = Uiuserinterfaceidiompad) #define Is_iphone (ui_user_interface_idiom () = = Uiuserinterfaceidiomphone) #define Is_retina ([[[UIScreen mainscreen] scale] >= 2.0) #define SCREEN_WIDTH ([[UIScreen Mainscreen] bounds].size.width) #define SCREEN_HEIGHT ([[UIScreen mainscreen] bounds].size.height) #define SCREEN_MAX_ LENGTH (MAX (Screen_width, screen_height)) #define SCREEN_MIN_LENGTH (MIN (Screen_width, screen_height)) #define Is_ Iphone_4_or_less (Is_iphone && screen_max_length < 568.0) #define IS_IPHONE_5 (Is_iphone && Screen_ Max_length = = 568.0) #define IS_IPHONE_6 (is_iphone && screen_max_length = 667.0) #define IS_IPHONE_6P (Is_iphone && screen_max_length = = 736.0)
4: Report an automatic layout bug in IOS8, while IOS8 can run normally
Will cause the app to hang, bug content: Terminating app due to uncaught exception ' nsinternalinconsistencyexception ', Reason: ' Auto Layout still R Equired after Executing-layoutsubviews.
UITableView ' s implementation of-layoutsubviews needs to call super '-(void) layoutsubviews{ //auto-layout content on Super Layoutsubviews front [self _updateconstraints]; [Super Layoutsubviews];}
5: Interaction with JS, and the JS code compatible with Android and iOS
JS Code: $ (function () {var u = navigator.useragent, app = Navigator.appversion; var isandroid = u.indexof (' Android ') >-1 | | U.indexof (' Linux ') >-1; Android Terminal or UC browser var Isios =!! 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 webJa Vascriptbackhome]; }} return YES; Note: Better iOS JS interactive third-party plugin webviewjavascriptbridge[Good instructions on how to use this plugin: http://www.henishuo.com/webviewjavascriptbridge-detail-use/]; You can use Safari to debug in iOS development debugging inline WebView It can be set up the development Mode menu, Development->ios Simulator can be implemented to view the operation of the Web page details (safari-> Preferences-Advanced-in the menu display "development");
If iOS is going to invoke the JS method, you can use stringbyevaluatingjavascriptfromstring as an example
iOS code:
-(Ibaction) SDFSDFSDF: (ID) Sender {
[Self.webview stringbyevaluatingjavascriptfromstring:[nsstring stringwithformat:@ "getMessageFromApp ('%@ ')", @ " Load End tune Sdfsdf method "]";
}
HTML code:
<script type= "Text/javascript" >
function Getmessagefromapp (message) {
var testdiv = document.getElementById ("Testdiv");
Testdiv.innertext = message;
}
</script>
iOS Development Basics-Fragmentation 11