我正在尝试使用情节提要实现2个Web视图,这两个视图都链接到另一个在线网页。
出于某种原因,我没有收到任何错误,但是只有PriceViewController有效。
另一个VC生成白页……

我正在使用以下4个文件:

PriceViewcontroller.h

#import <UIKit/UIKit.h>

 @interface PricesViewController : UIViewController

 {
     IBOutlet UIWebView *WebView; }

 @property (nonatomic, retain) UIWebView *WebView;

 @end

PriceViewController.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

最佳答案

这可能无法解决您的问题,但是请尝试此操作。相似地更改PricesViewController.hReservationsViewController.h。另外,您使用的是哪个版本的Xcode,以及您定位的是哪个iOS版本?如果您使用的是Xcode和iOS的最新版本,则.m中不需要@synthesize

@interface PricesViewController : UIViewController

@property (nonatomic, weak) IBOutlet UIWebView *WebView;

@end

不应保留IBOutlet,因为这可能会导致保留周期。可能不是原因,但无论如何还是好的编程习惯。

09-07 14:07