zoukankan      html  css  js  c++  java
  • How to use NSRequest in Delphi XE4

    //Demo How to use NSRequest..
    procedure TiOSWebBrowserService.DoNavigate(const URL: string);
    var
    NewURL: string;
    NSNewURL: NSURL;
    NSNewURLRequest: NSURLRequest;
    LPath: NSString;
    LFilePath: string;
    LDir, LFileName : string;
    Bundle : Pointer;
    begin
    NewURL := URL;
    if Pos('file://', URL) <> 0 then
    begin
    //extract the file name, the string after file://
    NewURL := Copy(URL, length('file://') + 1, length(URL));
    LDir := ExtractFileDir(NewURL);
    LFileName := ExtractFileName(NewURL);
    if LDir.IsEmpty then
    Bundle := TNSBundle.OCClass.mainBundle
    else
    Bundle := TNSBundle.OCClass.bundleWithPath(NSSTR(LDir));
    LPath := TNSBundle.Wrap(Bundle).pathForResource(NSSTR(LFileName), nil);
    if Assigned(LPath) then
    begin
    LFilePath := UTF8ToString(LPath.UTF8String);
    if not FileExists(LFilePath) then
    raise EFileNotFoundException.Create(SFileNotFound);
    NSNewURL := TNSURL.Wrap(TNSURL.OCClass.fileURLWithPath(LPath));
    end;
    end
    else
    begin
    if Pos('http', URL) = 0 then
    Insert('http://', NewURL, 0);
    NSNewURL := TNSUrl.Wrap(TNSUrl.OCClass.URLWithString(NSStr(NewURL)));
    end;
    NSNewURLRequest:= TNSURLRequest.Wrap(TNSURLRequest.OCClass.requestWithURL(NSNewURL));
    FWebView.loadRequest(NSNewURLRequest);
    FWebView.setFrame(CGRectFromRect(RectF(0, 0, 1, 1)));
    UpdateContentFromControl;
    end;

    //almost same with objective c style 

    ToCheck:  customized tableview cell . color / bg  / font/  in-app purchase subscribe

    Never giveup. Thanks the world.
  • 相关阅读:
    js数组条件筛选——map()
    (转)适用微信小程序的table表格(带隔行变色)
    nodejs学习笔记<七> 路由
    酷我音乐(在线试听)下载方法
    nodejs学习笔记<二> 使用node创建基础服务器
    JS BOM 窗口中的使用
    JS DOM
    JS 寄生 继承
    JS字面量创建方式的优缺点
    JS 构造函数
  • 原文地址:https://www.cnblogs.com/cnsoft/p/3174748.html
Copyright © 2011-2022 走看看