Listening for events in a UIWebView (iOS)

后端 未结 2 1171
猫巷女王i
猫巷女王i 2021-02-06 03:10

I\'m trying to listen for an event (specifically a button click) from a webpage I have opened in a UIWebView in my iOS app. I know that in other languages there are ways to att

2条回答
  •  醉酒成梦
    2021-02-06 03:53

    You can use the UIWebViewDelegate:

    - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
    

    The UIWebViewNavigationType values are :

    enum {
      UIWebViewNavigationTypeLinkClicked,
      UIWebViewNavigationTypeFormSubmitted,
      UIWebViewNavigationTypeBackForward,
      UIWebViewNavigationTypeReload,
      UIWebViewNavigationTypeFormResubmitted,
      UIWebViewNavigationTypeOther
    };typedef NSUInteger UIWebViewNavigationType;
    

    Can check this and then look at the NSURLRequest to get info about that

提交回复
热议问题