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

  • Home
  • SEARCH
  • 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 495383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:35:17+00:00 2026-05-13T05:35:17+00:00

I have two View Controllers: TableViewController (which is used as a modal view controller)

  • 0

I have two View Controllers: TableViewController (which is used as a modal view controller) and ToolbarController. In Interface Builder I have ToolbarView, which is controlled by the ToolbarController.

ToolbarView has an IBOutlet UIWebView that ToolbarController controls (uses buttons on a tool bar to switch pages in a webview).

What I need is the ability to have TableViewController to change the UIWebview in ToolbarView.

How can I accomplish this?

TableViewController.h:

#import <UIKit/UIKit.h>
#import "ToolbarController.h"
#import "MyAppDelegate.h"


@interface TableViewController : UITableViewController {
    NSMutableArray *widgetList;
    IBOutlet UIWebView *webView;
}

@property(nonatomic,retain) IBOutlet UIWebView *webView;

@end

TableViewController.m:

    #import "TableViewController.h"
    #import "MyAppDelegate.h"
    #import "ToolbarController.h"
    #import "TableView.h"

    @implementation TableViewController

    @synthesize webView;

    //Lots of working code omitted
//didSelectRowAtIndex below should change the webView in ToolbarView to Google's homepage but does not.

        - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
            NSString *urlAddress=[NSString stringWithFormat:@"http://www.google.com"];
            NSURL *url = [NSURL URLWithString:urlAddress];
            NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
            [webView loadRequest:requestObj];
            [self dismissModalViewControllerAnimated:YES];
        }

        - (void)viewDidUnload {
            // Release any retained subviews of the main view.
            // e.g. self.myOutlet = nil;
        }


        - (void)dealloc {
            [super dealloc];
        }


        @end
  • 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-13T05:35:17+00:00Added an answer on May 13, 2026 at 5:35 am

    I would suggest using delegation to handle this task. Set up a delegate protocol such as URLSelectionDelegate that will be implemented by your toolbar view controller. You’d probably just need one method, such as -urlSelectionDelegateDidSelectItemWithURL:(NSString *)selectedItemURL or similar. That way your modal table view controller is only responsible for its parent when an item was selected, and you keep all of your UIWebView-related logic in the same place, in the toolbar view controller.

    You would declare the delegate protocol in its own file, or simply in your toolbar view controller’s header, as such:

    @protocol URLSelectionDelegate <NSObject>
    - (void)urlSelectionDelegateDidSelectItemWithURL:(NSString *)selectedItemURL;
    @end
    

    Your web view controller would then implement this URLSelectionDelegate protocol, meaning that it implements the urlSelectionDelegateDidSelectItemWithURL: method:

    @interface TableViewController : UITableViewController <URLSelectionDelegate>
    // ...
    @end
    

    Now you’ll add a property to your modal table view controller named “delegate” or “urlSelectionDelegate”:

    @property (nonatomic, assign) id<URLSelectionDelegate> delegate;
    

    and set that to the parent view controller when it’s initialized:

    // Initialize table view controller (keep your existing code)
    TableViewController *vc = [[TableViewController alloc] init];
    // Assign the delegate
    [vc setDelegate:self];
    

    Now, in your didSelectRowWithIndexPath method, you’ll call the delegate method accordingly:

    if ([self delegate] != nil && [[self delegate] respondsToSelector:@selector(urlSelectionDelegateDidSelectItemWithURL:)) {
      [delegate urlSelectionDelegateDidSelectItemWithURL:@"http://www.google.com/";
    }
    

    Then just put the logic to change the web view inside the parent view controller.

    You can read a lot more about your different options in “What’s the best way to communicate between view controllers?” and you can learn more about the delegation pattern in Objective-C in How do I create delegates in Objective-C?

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

Sidebar

Ask A Question

Stats

  • Questions 372k
  • Answers 372k
  • 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 obviously we can't just delivery those path to image to… May 14, 2026 at 7:14 pm
  • Editorial Team
    Editorial Team added an answer unlink(__FILE__); for the "helper" file seems necessary since i cant… May 14, 2026 at 7:14 pm
  • Editorial Team
    Editorial Team added an answer Simplest solution: $converted_res = $res ? 'true' : 'false'; May 14, 2026 at 7:14 pm

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.