How load WebView with another URL when navigated through tab bar viewController

Posted by TechFusion on Stack Overflow See other posts from Stack Overflow or by TechFusion
Published on 2010-04-11T18:04:14Z Indexed on 2010/04/12 10:23 UTC
Read the original article Hit count: 862

Hello,

I have created window based application, root controller as Tab bar controller.

WebView is being loaded in Tab bar interfaced ViewController's View.WebView is created using IB.WebView object declared in ViewController as per below. //ViewController.h @interface ViewController:UIViewController{

IBOutlet UIWebview *Webview; } @property(nonatomic,retain)IBOutlet UIWebview *Webview; @end I am calling [WebView loadrequest] method in -viewDidLoad method and stopLoading will be called in -viewWillDisappear method.

I am again reload it in -viewWillAppear:animated method to load it again when tab bar is pressed.

//ViewController.m @implementation viewcontroller @synthesize Webview;

-(void)viewDidLoad{ [super viewDidLoad];

[self.Webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"www.apple.com"]]];

}

-(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [self.Webview reload]; } -(void)viewWillDisappear:(BOOL)animated{ [super viewWillDisappear:animated]; [self.Webview stopLoading]; }

I am releasing WebView in -ViewDidUnload method

-(void)viewDidUnload{ [super viewDidUnload]; [Webview release]; }

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

Does Webview released correctly ? Here how to kill connection with URL when ViewWillDisappear method called ? How to load View with Different URL then it's loaded in -viewDidLoad method when ViewController interfaced tab is pressed ? Means if naviagated from one tab to another that ViewController interface tab which has WebView should load request with another URL.

Does it correct to call [self.Webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"www.stackoverflow.com"]]]; this method again in -viewWillAppear:animated method to load with another URL ? Thanks,

© Stack Overflow or respective owner

Related posts about uitabbarcontroller

Related posts about uiwebview