2012-05-06 2 views

답변

3

그냥 뭔가 위치를 설정하여 답변

-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { 
.... 
// what to do here ?????? 
} 

감사 : 나는 또한있는 UIWebView를

function() { 
alert('test'); 
....   // How i can an objective c function here ??? 
} 

: 예를 들어 나는이처럼 내 myFile.js에 정의 된 자바 스크립트 기능이 request.URL이 일치하는지 확인하고 확인합니다.

function nav(f){ 
location.href = "methodCall"; 
} 

-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { 
    if([request.URL.relativeString isEqualToString:@"methodCall"]){ 
     //call method here 
     return false; //so it doesn't navigate anywhere 
    } 
    return true; //if you want every other link to work normally. 
} 

참고 :이 테스트를하지 않은하지만 request.URL.relativeString에 의해 반환 된 URL이 조금 다를 수 있지만 나는 그렇게 그냥 거기에 중단 점을 설정하고이 무엇인지를 참조하십시오, 그것은 작동합니다 상상한다.

관련 문제