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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:33:17+00:00 2026-05-14T07:33:17+00:00

I have an app with tabbar and webview. I’m trying to make the app

  • 0

I have an app with tabbar and webview. I’m trying to make the app come back to default url each time user taps the bar. Right now I’m intercepting taps and launching a method, however it’s not affecting my webview (it’s not loading the page). The method works properly when called from the class, but not when it’s called from my app delegate, where I’m intercepting taps.

I suspect it’s something with the way I create the SecondViewController object that it’s not pointing to the webview, but I have no clue what I’m doing wrong.

Here is the code:

Second view header (where the WebView is located)

@interface SecondViewController : UIViewController {
IBOutlet UIWebView *secondView;
}
- (void) goToPage;

Second view implementation

#import "SecondViewController.h"
@implementation SecondViewController
- (void)awakeFromNib 
{
    [self goToPage];
}

- (void) goToPage
{
    NSLog(@"go to page");
    NSString *newURL = [NSString stringWithFormat:@"http://pageurl"];
    [secondView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:newURL]]];
}

My app delegate, where I call the SecondViewController class method:

#import "RedDragonAppDelegate.h"
#import "SecondViewController.h"

@implementation RedDragonAppDelegate

@synthesize window;
@synthesize rootController;

- (void)applicationDidFinishLaunching:(UIApplication *)application {    
    // Override point for customization after application launch
    [window addSubview:rootController.view];
}

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {

    NSLog(@"didSelectViewController %d", rootController.selectedIndex);

    SecondViewController * sv = [[SecondViewController alloc] init];

    if (rootController.selectedIndex == 0){
        //NSLog(@"if in didSelectViewController 0");
    } else if (rootController.selectedIndex == 1) {
        //NSLog(@"if in didSelectViewController 1");
        [sv goToPage];
    }
}

Thanks fot your help!

  • 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-14T07:33:17+00:00Added an answer on May 14, 2026 at 7:33 am

    If I understand correctly, you’ve got an instance of SecondViewController with secondView connected to an instance of UIWebView in Interface Builder. What you want to do is call goToPage on that instance of SecondViewController from RedDragonAppDelegate. (In particular, note that I’m talking about instances of these–I believe this is the underlying issue.)

    In tabBarController:didSelectViewController:, when you do SecondViewController * sv = [[SecondViewController alloc] init];, you are creating a new instance of SecondViewController and you can call its goToPage method, but sv is not the same instance of SecondViewController that appears in Interface Builder and has secondView connected to the UIWebView (that is, when you create a new instance of SecondViewController, the ivar secondView is unset and seems to be nil, but I don’t know that it’s guaranteed to be nil).

    What you probably(*) want to do is add IBOutlet SecondViewController *sv; to the @interface of RedDragonAppDelegate, make sure that you have an instance of RedDragonAppDelegate in Interface Builder, connect the new IBOutlet sv of RedDragonAppDelegate to the instance of SecondViewController in Interface Builder, and delete the line in tabBarController:didSelectViewController: that defines and initializes sv.

    (*) I’m not 100% certain on this because I don’t do iPhone stuff and I don’t know how your various views/objects/etc. are arranged in XIB/NIB files, but if everything’s in one XIB/NIB file, I’m pretty sure it’ll work.

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

Sidebar

Related Questions

I have an app which could benefit from the user being able to choose
i have a tabbar app with 4 tabs. i want to add a small
I have a tabbar-based app with three tabs, one of them is a running
i am making a tabbar based app, but the problem is I have several
I have a tabbar-based iOS app with two tabs. When I tab into the
We have an app with an extensive admin section. We got a little trigger
I have an app that needs to open a new window (in the same
I have an app with a large ListView which is terribly slow so I'm
I have an app using PHP and the PayPal API. The basic way it
I have an app written in C# that lies on a network share. When

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.