溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

HTML5接入與OC交互

發(fā)布時間:2020-05-31 02:46:16 來源:網(wǎng)絡(luò) 閱讀:605 作者:卓行天下 欄目:軟件技術(shù)

////屏幕

#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:@"申請請求登錄?。?/span>" 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];

}





//隱藏頂部導(dǎo)航欄

- (void)viewWillAppear:(BOOL)animated {

      [self setFullScreen:YES];

  }


 - (void)viewWillDisappear:(BOOL)animated {

      [self setFullScreen:NO];

 }


 - (void)setFullScreen:(BOOL)fullScreen {

     // 狀態(tài)條

     [UIApplication sharedApplication].statusBarHidden = fullScreen;

   // 導(dǎo)航條

     [self.navigationController setNavigationBarHidden:fullScreen];

   // tabBar的隱藏通過在初始化方法中設(shè)置hidesBottomBarWhenPushed屬性來實現(xiàn)。

 }




@end



向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI