English 中文(简体)
从 j印功能到回收价值
原标题:calling xcode method from javascript function to and get returned value

im developing an app, which requires to load some menu s and presentations(pdf, flash etc.) menu items are loaded from database and each contains ID and Text. Menu items looks like below:

Crocin Combiflame

<>strong>above menu项目是超文本链接,点击将在同一页上开场白。

i 在这种情形下需要使用X代码方法,可以查询数据库(在文件夹中贴上相机)和返回介绍名称和其他细节。

i 这里有两个问题:

(1) i

**– webView:shouldStartLoadWithRequest:navigationType:**

但是,请见http://www.un.org/www.un.org。

2) 在同一个网页上,没有任何想法能够把介绍(在我的背书资料中)装上。

任何建议都将受到高度赞赏。 提前感谢。

问题回答

您可以做以下工作:webView:shouldStart LoadWithRequest:navigationType

  1. 如果您从中接回<>NO,那么网络观点将不满足目前的要求;这将使你能够不必做任何需要:

  2. 因此,你可以在同一网络观点中提出不同的要求(即采用列报资源的超文本说明),

  3. 或者,你可以向贵方的一些控制者发出一个信息,以管理不同的工作流程(显示一种不同的观点或任何观点)。

EDIT:

拟订更多的备选办法:

  1. 说你有一位看法控制器,把名称号码为IDWeb 观点和代表;

  2. 您可以确定一种看法控制器的方法,这种控制器可检索和超文本,并将它装入网络。

    - (void)loadContentInWebView:(NSString*)content {
         [_webView loadHTMLString:content  baseURL:nil];
    }
    
  3. now, in webView:shouldStartLoadWithRequest:navigationType, you could do something like this:

    - (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
            if ([[[request URL] absoluteString] isEqual:WHATEVER]) {
                 [self loadContentInWebView:HERE_THE_HTML];
                 return NO;
        }
        return YES;
    }
    

What you should define here is:

 ([[[request URL] absoluteString] isEqual:WHATEVER])

i. 用户触动应当加装介绍的某些链接时,可以理解的逻辑;

and:

  [self loadContentInWebView:HERE_THE_HTML];

i.e. 以某种方式界定了你希望用于展示的超文本内容。

i got a work around..although it is not a good practice:

in model: This method gets called whenever a request comes for this webview even when the page loads in webview

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
    // check the request, if it s ajax callback, just return NO; other wise YES;


//    NSURLRequest *request = [self request];
    NSURL *url = [request URL];

    NSString *file = [url lastPathComponent];
    if ([file isEqualToString:@"Presentation.html"] == YES) {
        return YES;
    }

    if ([file isEqualToString:@"ajaxcallback.htm"] == YES) {
        // that means the ajax call is done, so you can call this 
        NSString *result = [web stringByEvaluatingJavaScriptFromString:@"getResponse();"];

        // don t forget to stop loading this fake page
        return NO;
    }
}

和javascript:

   function sendRequestToApp(){
        window.location="http://www.domain.com/ajaxcallback.htm";
    }

    function getResponse(src){
        alert("response");
        document.getElementById("sample").src=src;
    }




相关问题
How to change out-of-focus text selection color in Xcode?

Okay, I ll bite. I ve got really pleasant code/window colors set up in Xcode. Ordinarily, my selection color is very visible. When I am doing a project search and iterating through the results, ...

Iphone NSTimer Issue

Hi I am new to objective c. I am trying to make an app for iphone. I have a button on my view, and the click on which the function playSound is called. This is working properly. It does plays the ...

Include a .txt file in a .h in C++?

I have a number of places where I need to re-use some template code. Many classes need these items In a .h could I do something like: #include <xxx.txt> and place all of this code in the ....

Iterating over string/strlen with umlauted characters

This is a follow-up to my previous question . I succeeded in implementing the algorithm for checking umlauted characters. The next problem comes from iterating over all characters in a string. I do ...

Xcode open two editor windows with same file

Is it possible to open the same file in two separate windows in Xcode. I can open a file in one window and the same file in the main Xcode editor window, but I wanted two separate fulltime editor ...

Forcing code signing refresh in Xcode

In our environment, we share resources across multiple projects and platforms. When building for iPhone, only a subset of those resources are needed. Since that subset is still considerable, we have ...

热门标签