add .gitignore
This commit is contained in:
254
msext/Class/RootVC/threeView.m
Executable file
254
msext/Class/RootVC/threeView.m
Executable file
@@ -0,0 +1,254 @@
|
||||
//
|
||||
// threeView.m
|
||||
// msext
|
||||
//
|
||||
// Created by chao on 17/3/1.
|
||||
// Copyright © 2017年 chao. All rights reserved.
|
||||
//
|
||||
|
||||
#import "threeView.h"
|
||||
#import <WebKit/WebKit.h>
|
||||
#import <WebKit/WKWebView.h>
|
||||
#import "Bridgetwo.h"
|
||||
@interface threeView ()
|
||||
<UIWebViewDelegate,UIActionSheetDelegate,webURLDelegatetwo>
|
||||
{
|
||||
UIWebView *webView_;
|
||||
BOOL flag;
|
||||
int orientation;
|
||||
}
|
||||
@property (copy, nonatomic) NSString *weburl;
|
||||
@property (copy, nonatomic) NSString *Navtitle;
|
||||
@end
|
||||
|
||||
@implementation threeView
|
||||
|
||||
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
|
||||
{
|
||||
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
|
||||
if (self) {
|
||||
// Custom initialization
|
||||
self.view.backgroundColor=[UIColor colorWithRed:249.0f/255 green:249.0f/255 blue:249.0f/255 alpha:1.0f];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
- (void)viewDidLoad {
|
||||
if([[[UIDevice currentDevice] systemVersion] floatValue]>=7.0) {
|
||||
self.edgesForExtendedLayout = UIRectEdgeNone;
|
||||
}
|
||||
[super viewDidLoad];
|
||||
flag=true;
|
||||
orientation=0;
|
||||
[FuncPublic SharedFuncPublic]._CurrentShow=3;
|
||||
// Do any additional setup after loading the view from its nib.
|
||||
// [FuncPublic InstanceLabel:@"版本 V7.0" RECT:CGRectMake(0, 165, 320, 38) RECT5:CGRectMake(0, 165, 320, 38) FontName:@"Arial-BoldMT" Red:52 green:52 blue:52 FontSize:18 Target:self.view Lines:0 TAG:-1 Ailgnment:1];
|
||||
}
|
||||
-(void)browser:(NSString *)url
|
||||
{
|
||||
NSString *encodeUrl = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
||||
NSLog(@"%@", encodeUrl);
|
||||
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:encodeUrl]];
|
||||
}
|
||||
|
||||
# pragma - table view delegate
|
||||
- (void)viewWillDisappear:(BOOL)animated
|
||||
{
|
||||
// [webView_ removeFromSuperview];
|
||||
// webView_ =nil;
|
||||
}
|
||||
-(void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
if([self.Navtitle isEqualToString:@""])
|
||||
{
|
||||
[self.navigationController setNavigationBarHidden:YES animated:NO];
|
||||
[self.navigationController.navigationBar setBackgroundImage:self BackgroundImage:[FuncPublic CreatedImageFromFile:@"RootNavBG" ofType:@"png"] LeftSel:@selector(PressBack:) RightSel:@selector(PressBack:) CenterSel:nil Title:self.Navtitle TempKind:3];
|
||||
if (webView_==nil) {
|
||||
if (orientation==1) {
|
||||
webView_ = [[UIWebView alloc] initWithFrame:CGRectMake(0,0,DEVH, DEVW)];
|
||||
|
||||
}else
|
||||
{
|
||||
webView_ = [[UIWebView alloc] initWithFrame:CGRectMake(0,0,DEVW, DEVH)];
|
||||
}
|
||||
|
||||
NSURLRequest *request =[NSURLRequest requestWithURL:[NSURL URLWithString:self.weburl]];
|
||||
[self.view addSubview: webView_];
|
||||
if (@available(ios 11.0,*))
|
||||
{
|
||||
UIScrollView.appearance.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
||||
webView_.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
||||
}
|
||||
[webView_ setDelegate:self];
|
||||
webView_.scrollView.bounces=NO;
|
||||
[webView_ loadRequest:request];
|
||||
[[FuncPublic SharedFuncPublic] UISwipeGestrue_Direction:self.view controllerview:self Direction:0 SEL:@selector(PressBack:)];
|
||||
}
|
||||
|
||||
}else
|
||||
{
|
||||
[self.navigationController setNavigationBarHidden:YES animated:NO];
|
||||
[self.navigationController.navigationBar setBackgroundImage:self BackgroundImage:[FuncPublic CreatedImageFromFile:@"RootNavBG" ofType:@"png"] LeftSel:@selector(PressBack:) RightSel:@selector(PressBack:) CenterSel:nil Title:self.Navtitle TempKind:3];
|
||||
if (webView_==nil) {
|
||||
if (orientation==1) {
|
||||
webView_ = [[UIWebView alloc] initWithFrame:CGRectMake(0,0,DEVH, DEVW)];
|
||||
|
||||
}else
|
||||
{
|
||||
webView_ = [[UIWebView alloc] initWithFrame:CGRectMake(0,0,DEVW, DEVH)];
|
||||
}
|
||||
NSURLRequest *request =[NSURLRequest requestWithURL:[NSURL URLWithString:self.weburl]];
|
||||
[self.view addSubview: webView_];
|
||||
if (@available(ios 11.0,*))
|
||||
{
|
||||
UIScrollView.appearance.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
||||
webView_.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
||||
}
|
||||
[webView_ setDelegate:self];
|
||||
webView_.scrollView.bounces=NO;
|
||||
[webView_ loadRequest:request];
|
||||
[[FuncPublic SharedFuncPublic] UISwipeGestrue_Direction:self.view controllerview:self Direction:0 SEL:@selector(PressBack:)];
|
||||
}
|
||||
|
||||
}
|
||||
if (orientation==1) {
|
||||
|
||||
|
||||
CGRect frame = [UIScreen mainScreen].applicationFrame;
|
||||
CGPoint center = CGPointMake(frame.origin.x + ceil(frame.size.width/2), frame.origin.y + ceil(frame.size.height/2));
|
||||
CGFloat duration = [UIApplication sharedApplication].statusBarOrientationAnimationDuration;
|
||||
[UIView beginAnimations:nil context:nil];
|
||||
[UIView setAnimationDuration:duration];
|
||||
//在这里设置view.transform需要匹配的旋转角度的大小就可以了。
|
||||
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
|
||||
if(orientation==UIInterfaceOrientationLandscapeRight)
|
||||
{
|
||||
webView_.transform=CGAffineTransformMakeRotation(-M_PI/2);
|
||||
}
|
||||
else{
|
||||
|
||||
webView_.transform=CGAffineTransformMakeRotation(M_PI/2);
|
||||
}
|
||||
webView_.center=center;
|
||||
[UIView commitAnimations];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
-(void)Openurl:(NSString *)url Title:(NSString *)title Data:(NSString *)data orientation_:(int)orientation_
|
||||
{
|
||||
// NSString* encodedString = [@"黄超" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
||||
//
|
||||
// NSString * encodedString2 = (NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,(CFStringRef)url,NULL,NULL,kCFStringEncodingUTF8);
|
||||
//
|
||||
// NSString *encodedString3 = (NSString *)
|
||||
// CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
|
||||
// (CFStringRef)url,
|
||||
// (CFStringRef)@"!$&'()*+,-./:;=?@_~%#[]",
|
||||
// NULL,
|
||||
// kCFStringEncodingUTF8);
|
||||
|
||||
// url=[url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
||||
//url [url stringByReplacingOccurrencesOfString:@"/" withString:@"%7C"];
|
||||
// url=[url stringByReplacingOccurrencesOfString:@"嘎嘎" withString:@"\\U560e\\U560e"];
|
||||
//NSString * htmlstr = [[NSString alloc]initWithContentsOfURL:[NSURL URLWithString:url] encoding:NSUTF8StringEncoding error:nil];
|
||||
// url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
|
||||
orientation=orientation_;
|
||||
// url = (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)url, nil, nil, kCFStringEncodingUTF8));
|
||||
// url=[url stringByReplacingOccurrencesOfString:@"%23" withString:@"#"];
|
||||
self.weburl=url;//[NSString stringWithFormat:@"%@&%@",url,encodedString];//url;
|
||||
//self.weburl=[self.weburl stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
|
||||
self.Navtitle=title;
|
||||
}
|
||||
|
||||
-(void)finishweb
|
||||
{
|
||||
[FuncPublic PopAnimation:self];
|
||||
}
|
||||
- (void) webViewDidStartLoad:(UIWebView *)webView
|
||||
{
|
||||
[[FuncPublic SharedFuncPublic]StartActivityAnimation:self];
|
||||
NSLog(@"webViewDidStartLoad");
|
||||
}
|
||||
|
||||
- (void) webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
|
||||
{
|
||||
NSLog(@"didFailLoadWithError:%@", error);
|
||||
}
|
||||
-(void)PressBack:(id)sender
|
||||
{
|
||||
[FuncPublic PopAnimation:self];
|
||||
}
|
||||
- (void)cleanCacheAndCookie{
|
||||
//清除cookies
|
||||
NSHTTPCookie *cookie;
|
||||
NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
|
||||
for (cookie in [storage cookies]){
|
||||
[storage deleteCookie:cookie];
|
||||
}
|
||||
//清除UIWebView的缓存
|
||||
[[NSURLCache sharedURLCache] removeAllCachedResponses];
|
||||
NSURLCache * cache = [NSURLCache sharedURLCache];
|
||||
[cache removeAllCachedResponses];
|
||||
[cache setDiskCapacity:0];
|
||||
[cache setMemoryCapacity:0];
|
||||
}
|
||||
|
||||
-(void)backgameData:(NSString *)data
|
||||
{
|
||||
// [self cleanCacheAndCookie];
|
||||
//[FuncPublic PopAnimation:self];
|
||||
// [self.navigationController popViewControllerAnimated:YES];
|
||||
// [[NSNotificationCenter defaultCenter] postNotificationName:@"backgameDatatwo" object:data];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self PressBack:nil];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:@"backgameDatatwo" object:data];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
-(void)dealloc
|
||||
{
|
||||
SG_RELEASE(webView_);
|
||||
[super dealloc];
|
||||
|
||||
|
||||
}
|
||||
|
||||
- (void)webViewDidFinishLoad:(UIWebView *)webView
|
||||
{
|
||||
[[FuncPublic SharedFuncPublic]StopActivityAnimation];
|
||||
NSLog(@"webViewDidFinishLoad");
|
||||
|
||||
JSContext *context = [webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
|
||||
|
||||
Bridgetwo *jo = [[Bridgetwo alloc] init];
|
||||
context[@"settings"] = jo;
|
||||
context.exceptionHandler = ^(JSContext *context, JSValue *exceptionValue) { context.exception = exceptionValue; NSLog(@"异常信息:%@", exceptionValue); };
|
||||
jo.delegate=self;
|
||||
|
||||
|
||||
|
||||
|
||||
[webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.style.webkitUserSelect='none';"];
|
||||
[webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.style.webkitTouchCallout='none';"];
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
#pragma mark - Navigation
|
||||
|
||||
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
||||
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
||||
// Get the new view controller using [segue destinationViewController].
|
||||
// Pass the selected object to the new view controller.
|
||||
}
|
||||
*/
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user