views:

262

answers:

3

I've been messing around with some open source code trying to figure cocoa out. I've gotten an application with multiple views, and I want to put UIWEBVIEWS on the second, third, and fourth view controllers i've made. However for the life of me I can't seem to figure it out I can actually pull down on the touch screen a black/blank UIWEBVIEW on the fourth view controller when I run it on my iphone. I thinks it's just missing the following URL code. any guru's know where I need to put it?

[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://xbox-scene.com"]]];

Heres link to the Xcode Project file. THANKS all! http://rapidshare.com/files/340904297/Lane.zip.htm

A: 

Have you looked at UIViews' viewDidLoad: method? It will be invoked when the view is retrieved from a nib. You can place your loadRequest there.

EightyEight
Here's the code from my fourthviewcontroller.m: - (void)viewDidLoad { [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://xbox-scene.com"]]]; // segmented control action [myControl addTarget:self action:@selector(loadAnotherView:) forControlEvents:UIControlEventValueChanged]; [super viewDidLoad]; }Thats what i thought. Yet it's a no go...I don't think i'm totally off base here but maybe I am.
William Simpson
A: 

Here's the code in a little better view from my fourthviewcontroller.m:

  • (void)viewDidLoad {

[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://xbox-scene.com"]]];

// segmented control action
[myControl addTarget:self 
          action:@selector(loadAnotherView:) 
    forControlEvents:UIControlEventValueChanged];
[super viewDidLoad];

}

Thats what i thought. Yet it's a no go...I don't think i'm totally off base here but maybe I am.

William Simpson
A: 

The XIB file for the fourth view in the source code provided suggests that you are creating two instances of FourthViewController (one being the File's owner itself).

The UIWebview object in the view is connected to the 'webview' property of the second FourthViewController instance to which no view is connected and being loaded. So its -viewDidLoad method never gets called and hence the webpage never gets loaded.

If you remove the second instance and connect the webview property from the Files owner to the UIWebview object then the code should work fine. It did for me.

Deepak