I have the following:
@interface HelpViewController : UIViewController <UIWebViewDelegate>
@property (nonatomic, retain) IBOutlet UIWebView *webView;
@end
And for the same view controller
@implementation HelpViewController
@synthesize webView = _webView;
- (void) viewDidLoad
{
[super viewDidLoad];
NSString *filePath=[[NSBundle mainBundle] pathForResource:@"test" ofType:@"html"];
NSLog(@"%@", filePath);
[self.webView loadData:[NSData dataWithContentsOfFile:filePath]
MIMEType:@"text/html"
textEncodingName:@"UTF-8"
baseURL:nil];
}
And a basically empty nib to go with this view controller. The file's owner is has an outlet to view. The file path comes back OK. But nothing shows up in the view. I think the problem is that IBOutlet UIWebView *webView is not connected to anything, ’cause I don’t know what to connect it to. Is that the problem? If so I need to know what to connect it to; otherwise, I need any kind of help! Thanks!
EDIT: Forgot to mention that I think I have the same problem as this SO Question where it says to connect the outlet, but doesn’t say to what.
Alright, after a lot of study of other SO pages and some non-SO material, I figured out that I had not added a web view from the library to the nib. So that’s why I couldn’t hook it up. So I made sure first that the ‘regular’ view was hooked up, added the web view from the library and hooked up it’s view. Then I needed the following additional line in my code:
to
viewDidLoad. Whew!