温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

HTML5接入与OC交互

发布时间:2020-05-31 02:46:16 来源:网络 阅读:604 作者:卓行天下 栏目:软件技术

////屏幕

#define SHENGHUO_WIDTH    ([UIScreen mainScreen].bounds.size.width)

#define SHENGHUO_HEIGHT   ([UIScreen mainScreen].bounds.size.height)


#import "SHFindVC.h"

//

////HTML5接入测试

//#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"];

    //正式服

    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:@"提示" message:@"申请请求登录!!" delegate:nil cancelButtonTitle:@"确定" 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];

}





//隐藏顶部导航栏

- (void)viewWillAppear:(BOOL)animated {

      [self setFullScreen:YES];

  }


 - (void)viewWillDisappear:(BOOL)animated {

      [self setFullScreen:NO];

 }


 - (void)setFullScreen:(BOOL)fullScreen {

     // 状态条

     [UIApplication sharedApplication].statusBarHidden = fullScreen;

   // 导航条

     [self.navigationController setNavigationBarHidden:fullScreen];

   // tabBar的隐藏通过在初始化方法中设置hidesBottomBarWhenPushed属性来实现。

 }




@end



向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI