English 中文(简体)
切换到书盘中的另外一个视图, 并共享数据到新视图
原标题:Change View to another View within a Storyboard and share data to the new view

有个问题, 我试图回到先前的视图, 并分享一些数据到返回到的框架。 数据将是日期和时间, 我想将数据发送到文本字段 。

例如,我调用日期 * 返回日期 和文本 字段 I 调用日期 * 时间 。 视图称为 * PickDateTime 和 subjectEventsP2 。

如果你需要更多的信息 只要问我,我会补充它 如果我能让你更容易 帮助我。

我使用Xcode4.2。

最佳回答

好,很简单,你应该使用一个代表... 如果我理解正确,你是在第二个视图, 当你回到主视图时, 你想把数据从第二个视图 发回主视图,对不对?

因此,在你的第二种观点中,在.h档案中,在接口的顶端,你将宣布该代表:

@class nameOfTheViewController;

@protocol nameOfTheViewControllerDelegate <NSObject>
-(void)methodNameOfDelegateReturning:(NSString *)string otherString:(NSString *)string2;
@end

在您的界面,仍然在.h, 你会创建一个参考 这个代表像:

@property(nonatomic, weak) id <nameOfTheViewControllerDelegate> delegate;

之后,在你的.m 名字 The View Gunator 你会做:

@synthesize delegate = _delegate;

在您以 TheView Conserenter 文件的名称创建了您的代表文件之后, 您将调用您刚刚创建的代表方法, 具体位置和当您想要返回到前一个视图时, 填满您想要传递的参数... 当然, 在您的主 View Control 中, 您的 PrepareForSegue 方法中, 您将创建一个名为 TheTheView Conserenter 类的例子, 并设置其代表 proeprty 给自己..., 这样才能实现这一点, 在您的主 View cutor 中. h 您必须符合名为“ TheView ConcentDelgate 协议 ” 。

问题回答

暂无回答




相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签