iOS access to Safari Reader feature through UIWebView

前端 未结 6 694
梦如初夏
梦如初夏 2020-12-23 18:19

I am using iOS 4.3 & was wondering if there is any way that I can access the Safari\'s \"Reader\" feature through which webpages are removed of ads & other riff raff

6条回答
  •  伪装坚强ぢ
    2020-12-23 18:37

    You can do it in iOS9. first import SafariServices:

    #import 
    

    Afterwards we are instantiating SFSafariViewController and adding it as a subview. We have two options doing so:

    • Creating with only base URL
    • Creating with bas URL as well as entering 'Reading Mode' in case it is available
    NSString *sURL = @"http://google.com";
    
    NSURL *URL = [NSURL URLWithString:sURL];
    
    SFSafariViewController *safari = [[SFSafariViewController alloc] initWithURL:URL]; // 1.
    
    SFSafariViewController *safari = [[SFSafariViewController alloc] initWithURL:URL entersReaderIfAvailable:YES]; // 2.
    
    [self presentViewController:safari animated:YES completion:nil];
    

提交回复
热议问题