将数据从一个视图控制器传递到另一个 [英] Passing data from one viewcontroller to another

查看:43
本文介绍了将数据从一个视图控制器传递到另一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我子类化了两个视图控制器.

I subclassed two view controllers.

第一个应该传递数据,一个 NSUrl 对象到第二个.

The first one is supposed to pass data, a NSUrl object to the second one.

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

It is obviously not working and not compiling,telling me essentially that I didn't subclass it and that the property urlToUse is not found on UIViewController.

我如何正确地进行子类化?

How do I subclass correctly?

谢谢!

推荐答案

正确的代码

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

这篇关于将数据从一个视图控制器传递到另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆