UIWebView - How to Disable Action Sheets (UIActionSheet)?

血红的双手。 提交于 2019-12-03 07:13:54

问题


I would like to know how you can disable UIActionSheets, specifically the Action Sheets being displayed after tapping and holding hyperlinks in a UIWebView. These seem to be enabled by default in UIWebViews containing the link address of the respective link in the title of the alert. They are also enabled in Safari.

(How) is it possible to disable all Action Sheets of this kind within a UIWebView?

Thanks in advance!


回答1:


I just found this solution myself. Add this to your CSS:

body {
  -webkit-touch-callout: none;
}

To be clear, this disables the action sheet that appears when you hold down a hyperlink.




回答2:


You can also handle this via JavaScript by calling:

document.documentElement.style.webkitTouchCallout = "none";



回答3:


 - (void)webViewDidFinishLoad:(UIWebView *)webView
 {
    [webView stringByEvaluatingJavaScriptFromString:@"document.body.style.webkitTouchCallout='none'; document.body.style.KhtmlUserSelect='none'"];
 }



回答4:


The dataDetectorTypes property might be what you are looking for. If you want to disable that action sheet possibility, just insert the code:

webView.dataDetectorTypes = UIDataDetectorTypeNone;



回答5:


You can override presentViewController in UINavigationController and do nothing like this.

@implementation CDVInAppBrowserNavigationController : UINavigationController

- (void)presentViewController:(UIViewController *)viewControllerToPresent animated: (BOOL)flag completion:(void (^ __nullable)(void))completion NS_AVAILABLE_IOS(5_0){
    //Do nothing.
}

@end


来源:https://stackoverflow.com/questions/2808267/uiwebview-how-to-disable-action-sheets-uiactionsheet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!