从另一个 ViewController 获取 NSDate 到 titleForHeaderInSection
我有两个视图,第一个是日历,第二个是带有 tableView
的 UIView; 我正在尝试显示从第一个视图中选择的日期。设法在我的 secondaryView 的 ViewDidLoad 方法中获取所选日期。
如何将我的 NSDate
添加到我的 - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
方法?
I have two views, first one is with calendar and the second one is a UIView with a tableView
;
I'm trying to display the selected date from the firstView. Managed to get the selected date inside ViewDidLoad
method of my secondView.
How I add my NSDate
to my - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
method?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 TableViewController 上声明一个
@property (nonatomic, keep) NSDate *displayDate;
(或者在使用 ARC 时使用strong
而不是retain
)(不要忘记来合成)。然后,第一个视图可以设置 TableViewController 的属性,例如:然后,您可以使用
self.displayDate
从 TableViewController 中访问日期,例如在titleForHeaderInSection
中。Declare an
@property (nonatomic, retain) NSDate *displayDate;
(orstrong
instead ofretain
when using ARC) on your TableViewController (dont forget to synthesize). The first view can then set the property of the TableViewController, for example:You can then access the date from within your TableViewController using
self.displayDate
, for example in yourtitleForHeaderInSection
.