0

我继承了两个视图控制器。

第一个应该传递数据,一个 NSUrl 对象给第二个。

第一个的.m:

NSURL *temp = [NSURL URLWithString:@"http://example.com"];

UIViewController *presentationsFullScreen_ViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"PresentationsFullScreen_ViewController"];

presentationsFullScreen_ViewController.urlToUse = temp;

第二个的.h:

#import <UIKit/UIKit.h>

@interface PresentationsFullScreen_ViewController : UIViewController {


    NSURL *urlToUse;


}



@property (nonatomic,retain) NSURL *urlToUse;

它显然不工作也不编译,基本上告诉我我没有子类化它,并且在 UIViewController 上找不到属性 urlToUse。

我如何正确子类化?

谢谢!

4

2 回答 2

1

这是正确的代码

 PresentationsFullScreen_ViewController *presentationsFullScreen_ViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"PresentationsFullScreen_ViewController"];
presentationsFullScreen_ViewController.urlToUse = temp;
于 2012-10-12T21:27:15.773 回答
0

解决方案:

不要忘记导入 .h:

#import "PresentationsFullScreen_ViewController" 

并且不要使用 UIViewController 实例化对象,而是使用子类的名称:

PresentationsFullScreen_ViewController *presentationsFullScreen_ViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"PresentationsFullScreen_ViewController"];
于 2012-10-12T21:32:44.800 回答