Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8060535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:01:24+00:00 2026-06-05T10:01:24+00:00

I have an UIWebview and it’s loading a particular website section (news). And I

  • 0

I have an UIWebview and it’s loading a particular website section (news). And I want to block the users to access other part of the site, meaning they should only stay in the news section / reading the pdf articles.

I’ve constructed a set of code, but sadly unable to test them out just yet due to some technical constraint. Will only be able to access it next week. However, I thought it will be a good time to ask here and let the advance user view my draft code and see if its feasible.

- (void)viewDidLoad
{   
    [super viewDidLoad];

    NSString *urlAddress = @"http://www.imc.jhmi.edu/news.html";
    NSURL *url =[NSURL URLWithString:urlAddress];
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
    [webView loadRequest:requestObj];

    //finding current url and lead it back if it strayed off
    NSString *currentURL = webView.request.URL.absoluteString;
    NSRange range1 = [currentURL rangeOfString:@"news"];
    NSRange range2 = [currentURL rangeOfString:@"pdf"];

Should I use

    if (range1.location ==NSNotFound){
    currentURL = @"http://www.imc.jhmi.edu/news.html";
    [webView reload];
    }else if (range2.location ==NSNotFound){
    currentURL = @"http://www.imc.jhmi.edu/news.html";
    [webView reload];
    }

}

Or this set of code?

    if (range1.location ==NSNotFound){
    currentURL = @"http://www.imc.jhmi.edu/news.html";
    url = [NSURL URLWithString:currentURL
    [webView loadRequest:[NSURLRequest requestWithURL:url]];
    }else if (range2.location ==NSNotFound){
    currentURL = @"http://www.imc.jhmi.edu/news.html";
    url = [NSURL URLWithString:currentURL
    [webView loadRequest:[NSURLRequest requestWithURL:url]];
    }

And is there any problem with the code? if yes, please point out why it wouldn’t work as I’m still in learning phase. Would be a great opportunity to learn more at this stage. The logic I’m looking for is it will load the initial news section. UIWebView should only display the news section / PDF articles from there. If the user try to go to other path, it should detect the current url and redirect them back to news section.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T10:01:27+00:00Added an answer on June 5, 2026 at 10:01 am

    To restrict the load of certain url do the following

    webView.delegate = self;
    

    And add the following function

    - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
    {
         NSString *urlString = [[request URL]absoluteString];
         if(ulrString == @"restricted ur")
              return NO;   //Restrict
         else
              return YES;  //Allow
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UIWebView in my app which I want to use to display
I have a UIWebView that loads a link, http://www.google.com/a/datacommsales.net . But I want to
I have a UIWebView named wView. I want to use webViewDidFinishLoad: in my class,
I have a UIWebView that loads a website. Then in - (void)webViewDidFinishLoad:(UIWebView *)webView I
I have a UIWebView and I have a custom font I want to load
I have a UIWebView i want to introduce functionality of content(may be text or
I have a UIWebView that I am loading with a string full of HTML.
I have a UIWebView with a navigation bar and toolbar that I want to
I have a UIWebView which I want to put under my translucent UINavigationBar. Normally
I have a UIWebView and I want to set one of it's text field

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.