我正在尝试使用故事板实现2个Web视图,这两个视图都链接到另一个在线网页。 出于某种原因,我没有得到任何错误,但只有PriceViewController工作。 另一个VC生成白页......
我正在使用这4个文件:
PricesViewcontroller.h
#import <UIKit/UIKit.h>
@interface PricesViewController : UIViewController
{
IBOutlet UIWebView *WebView; }
@property (nonatomic, retain) UIWebView *WebView;
@end
PricesViewController.m
#import "PricesViewController.h"
@interface PricesViewController ()
@end
@implementation PricesViewController @synthesize WebView;
- (void)viewDidLoad {
[WebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.sparein.be/full_pricelist.pdf"]]];
[super viewDidLoad];
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self; }
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated. }
@end
ReservationsViewController.h
#import <UIKit/UIKit.h>
@interface ReservationsViewController : UIViewController
{
IBOutlet UIWebView *WebView2; }
@property (nonatomic, retain) UIWebView *WebView2;
@end
ReservationsViewController.m
#import "ReservationsViewController.h"
@interface ReservationsViewController ()
@end
@implementation ReservationsViewController @synthesize WebView2;
- (void)viewDidLoad {
[WebView2 loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.be"]]];
[super viewDidLoad];
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self; }
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated. }
@end
答案 0 :(得分:1)
这可能无法解决您的问题,但请尝试此操作。同样更改您的PricesViewController.h
和ReservationsViewController.h
。此外,您使用的是什么版本的Xcode,以及您定位的iOS版本是什么?如果您使用的是最新版本的Xcode和iOS,则不应该在.m中使用@synthesize
。
@interface PricesViewController : UIViewController
@property (nonatomic, weak) IBOutlet UIWebView *WebView;
@end
不应保留 IBOutlet
,因为这会导致保留周期。可能不是原因,但无论如何都是良好的编程习惯。