3

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

我正在使用这 4 个文件:

价格视图控制器.h

#import <UIKit/UIKit.h>

 @interface PricesViewController : UIViewController

 {
     IBOutlet UIWebView *WebView; }

 @property (nonatomic, retain) UIWebView *WebView;

 @end

价格视图控制器.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

预订视图控制器.h

#import <UIKit/UIKit.h>

 @interface ReservationsViewController : UIViewController

 {
     IBOutlet UIWebView *WebView2; }

 @property (nonatomic, retain) UIWebView *WebView2;

 @end

预订视图控制器.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
4

1 回答 1

1

这可能无法解决您的问题,但试试这个。改变你的PricesViewController.hReservationsViewController.h类似的。另外,你使用的是什么版本的 Xcode,你的目标是什么版本的 iOS?@synthesize如果您使用的是最新版本的 Xcode 和 iOS,则不需要在 .m 中。

@interface PricesViewController : UIViewController

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

@end

IBOutlets 不应该被保留,因为这会导致保留循环。可能不是原因,但无论如何都是良好的编程习惯。

于 2013-09-03T13:53:38.590 回答