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 514977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:34:50+00:00 2026-05-13T07:34:50+00:00

I have a navigation-based application with 2 UIViewControllers (controller-2 is pushed onto controller-1 when

  • 0

I have a navigation-based application with 2 UIViewControllers (controller-2 is pushed onto controller-1 when the user selects a particular row within a UITableView displayed using controller-1).

Here’s the ‘twist’… When controller-1 is loaded, I want to “prefetch” a URL containing HTML/javascript into a UIWebView. Initially, the user won’t see this UIWebView. Instead they will see a UITableView allowing them to click on 5 different options (row0, row1, row2, row3, row4).

When the user selects a row I would like to push a new view onto the stack and “pass” the HTML/Javascript to a UIWebView located within this new view, and display the web-page in the new view.

Is it possible to pass the UIWebView like this?

I’ve tried the following, which is not displaying the HTML within UIWebView, so any suggestions on how to pass the UIWebView (or alternatives) would be great. I’m pretty sure I’ve made the correct connections within my nib file for controller2.

To explain my motives. I want to use javascript to hide certain elements of the web-page depending on which row the user clicks. To me, it’s faster and easier to make 1 URL request and then use javascript to hide various HTML elements than it is to make 5 different URL requests, fetching 5 separate web-pages. So, if there are alternative thoughts to this approach, that would be great, too. I thought about doing this all within 1 viewcontroller (adding and removing subviews), but I’d rather push onto a new view to take advantage of the navigation controller.

TYVM!!!!

////////// controller 1 //////////////////////

- (void)viewWillAppear:(BOOL)animated {
  // do other stuff ///
  NSURLRequest    *request_object = [NSURLRequest requestWithURL:self.url];
  [self.web_view1 loadRequest:request_object];         
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    self.view_controller2             = [[[ViewController2 alloc]   initWithNibName:@"ViewController2" bundle:nil] autorelease];
    self.view_controller2.web_view2   = self.web_view1;
    [self.navigationController        pushViewController:self.view_controller2 animated:YES];
}
//////////// controller 1 //////////////////////

//

///////////// portion of controller 2 header file /////////////////////////

@interface ViewController2 : UIViewController {
    IBOutlet UIWebView *web_view2;
}
@property (nonatomic, retain) IBOutlet UIWebView *web_view2;


//////////// portion of controller 2 implementation file //////////////
#import "ViewController2.h"

@implementation ViewController2
@synthesize web_view2;

- (void)dealloc {
    [web_view2 release], web_view2 = nil;
    [super dealloc];
}

//////////// controller 2 //////////////////////////
  • 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-05-13T07:34:50+00:00Added an answer on May 13, 2026 at 7:34 am

    You’ve got the right idea, but you need to do one other thing. In your -tableView:didSelectRowAtIndexPath:. you need to add the webview to the viewController’s view, not just assign it to an outlet. The following might work, depending on your XIB files:

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
      self.view_controller2 = [[[ViewController2 alloc] initWithNibName:@"ViewController2" bundle:nil] autorelease];
      self.web_view1.frame = self.view_controller2.web_view2.frame;
      [self.view_controller2.web_view2 removeFromSuperview];
      self.view_controller2.web_view2 = self.web_view1;
      [self.view_controller2.view addSubview: self.web_view1];
      [self.navigationController pushViewController:self.view_controller2 animated:YES];
    }
    

    This assumes that web_view2 is a valid and hooked up outlet, containing a webview in the location you want your ‘cached’ view to be.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 390k
  • Answers 390k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer A very simple solution is to validate the filename on… May 15, 2026 at 1:08 am
  • Editorial Team
    Editorial Team added an answer you can save a history of the last 5 passwords… May 15, 2026 at 1:08 am
  • Editorial Team
    Editorial Team added an answer It's fairly complicated but this should get you further. You… May 15, 2026 at 1:08 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.