Lance
Lance

Reputation: 9012

Make a UIWebView Public

I have a UIWebView object declared in my view controller and I want to make it load a different page when the app recieves a notification while the app is running using application:didRecieveRemoteNotification:. I'm having trouble accessing the object from inside the appDelegate.

Any simple way to do this?

this is how I declare my web view

.h

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

.m

@synthisize webView;
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:currentPath]]];

Upvotes: 0

Views: 355

Answers (1)

Max
Max

Reputation: 16719

this is not the best idea to show the web view from outside the controller. Just add method like this to controller:

-(void) loadFromPath:(NSString*) path {
      [webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath: path]]];
}

and call it in your app delegate when you need.

Upvotes: 2

Related Questions