HTML5 access and OC interaction
/ screen
# define SHENGHUO_WIDTH ([UIScreen mainScreen] .bounds.size.width)
# define SHENGHUO_HEIGHT ([UIScreen mainScreen] .bounds.size.height)
# import "SHFindVC.h"
/ /
/ HTML5 access test
/ / # import "WebViewJavascriptBridge.h"
/ / # import "Html5ReportWebView.h"
@ interface SHFindVC ()
@ end
@ implementation SHFindVC
-(void) viewDidLoad {
[super viewDidLoad]
_ commodityHtml.delegate=self
NSUserDefaults * userInfo = [NSUserDefaults standardUserDefaults]
NSMutableArray * userid = [userInfo objectForKey:@ "userId"]
/ / formal service
NSString * newUrl = [NSString stringWithFormat:@ "% @", userid]
NSLog (@ "% @", newUrl)
NSURL * htmlUrl = [NSURL URLWithString:@ "http://"];
NSURL * url = [NSURL URLWithString: [NSString stringWithFormat:@ "% @% @", htmlUrl,newUrl]]
NSLog (@ "% @", url)
[_ commodityHtml loadRequest: [NSURLRequest requestWithURL:url]]
}
-(BOOL) webView: (UIWebView *) webView shouldStartLoadWithRequest: (NSURLRequest *) request navigationType: (UIWebViewNavigationType) navigationType {
NSString * absoluteString = request.URL.absoluteString
NSLog (@ "TAP = =% @", absoluteString)
If ([absoluteString rangeOfString:@ "login"] .location! = NSNotFound) {
UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@ "prompt" message:@ "to apply for login request!" Delegate:nil cancelButtonTitle:@ "OK" otherButtonTitles: nil]
[alertView show]
}
Return YES
}
-(IBAction) addContent: (id) sender {
NSString * js = @ "var p = document.createElement ('p'); p.innerText = 'new Line';document.body.appendChild (p);"
[_ commodityHtml stringByEvaluatingJavaScriptFromString:js]
}
/ / hide the top navigation bar
-(void) viewWillAppear: (BOOL) animated {
[self setFullScreen:YES]
}
-(void) viewWillDisappear: (BOOL) animated {
[self setFullScreen:NO]
}
-(void) setFullScreen: (BOOL) fullScreen {
/ / status bar
[UIApplication sharedApplication] .statusBarHidden = fullScreen
/ / Navigation bar
[self.navigationController setNavigationBarHidden:fullScreen]
/ / the hiding of tabBar is achieved by setting the hidesBottomBarWhenPushed property in the initialization method.
}
@ end