I’m just starting to learn Xcode, and have run in to some problems…
I’ve made a tabbed application in Xcode 4.3 which works as deired. But I previously made a simple UIWebView application, that I would now like to implement into one of the tabs on the new application.
This is what I’ve done in the classes for FirstViewController:
// FirstViewController.h
// SafeLine
//
// Created by Camilla Fröberg on 2012-03-27.
// Copyright (c) 2012 SafeLine Sweden AB. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface FirstViewController : UIViewController {
IBOutlet UIWebView *webDisplay;
}
@property(nonatomic,retain) UIWebView *webDisplay;
@end
And the FirstViewController.m:
// FirstViewController.m
// SafeLine
//
// Created by Camilla Fröberg on 2012-03-27.
// Copyright (c) 2012 SafeLine Sweden AB. All rights reserved.
//
#import "FirstViewController.h"
@interface FirstViewController ()
@end
@implementation FirstViewController
@synthesize webDisplay;
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
NSString *urlAddress = @"http://www.google.com";
//Create a URL object.
NSURL *url = [NSURL URLWithString:urlAddress];
//URL Requst Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
//Load the request in the UIWebView.
[webDisplay loadRequest:requestObj];
[super viewDidLoad];
}
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
@end
When running the application I won’t get any error message, and it will not show the website, instead it will only show an empty view…
Any help is appreciated!
// Best regards
Camilla from Sweden
I think, you should check if you connected the UIWebView in the Interface Builder with IBOutlet.