Re: Call UIWebView From Different Class File.
Re: Call UIWebView From Different Class File.
- Subject: Re: Call UIWebView From Different Class File.
- From: Izidor Jerebic <email@hidden>
- Date: Sun, 24 Jan 2010 15:38:35 +0100
Hi,
You can't directly access stuff in separate xib file.
You need to pass the url to the second controller, and then the second
controller can then do whatever is necessary to show the url in its
own xib.
izidor
On 24.1.2010, at 14:18, Philip Juel Borges wrote:
Hi,
OBJECTIVE
When I press a button in one XIB file (View1), I would like to
display an html file in a UIWebView that is located in a separate
XIB file (View2).
This is what I have so far.
View1ViewController.h:
@interface View1ViewController : UIViewController {
IBOutlet UIWebView *webView;
}
@property (nonatomic, retain) IBOutlet UIWebView *webView;
- (IBAction)loadHTMLFile;
View1ViewController.m:
#import "View1ViewController.h"
#import "View2ViewController.h"
@implementation View1ViewController
@synthesize webView;
- (IBAction)loadHTMLFile {
View2ViewController *go = [[View2ViewController alloc]
initWithNibName:@"View2" bundle:nil];
[self presentModalViewController:go animated:YES];
NSURL *baseURL = [NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:@"1" ofType:@"html" inDirectory:@"Pubs/rbi8/co"]];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL
URLWithString:[NSString stringWithFormat:@"%@#1",[baseURL
absoluteString]]]]];
}
I can load View2.xib no problem, but nothing is put in the webview.
If the webview is in View1.xib the html file loads nicely. But,
instead of using the UIWebView that is in View1.xib I would like to
load the html file in a UIWebView put in View2.xib. So they have to
communicate across I guess. I've tried to work with UIApplication
sharedApplication, but doesn't work (or mayby I'm doing it wrong).
If I remove the UIWebView outlet from View1ViewController I
naturally get errors, so I 've been thinking how I would let the
webView variable in the loadHTMLFile method of View1ViewController.m
know that it is connected to the UIWebView of View2.xib?
I hope this is clear and that you can point me in the right
direction. Thanks for any help you may provide.
--Philip
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden