我刚刚开始学习Xcode,并遇到了一些问题......
我在Xcode 4.3中制作了一个带标签的应用程序,它可以作为deired使用。但我之前创建了一个简单的UIWebView应用程序,现在我想在新应用程序的一个选项卡中实现。
这是我在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
和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
运行应用程序时,我不会收到任何错误消息,也不会显示网站,而只会显示空视图...
感谢任何帮助!
//祝你好运 来自瑞典的卡米拉
答案 0 :(得分:0)
我认为,您应该检查是否将Interface Builder中的UIWebView与IBOutlet连接。