get NSDate into titleForHeaderInSection from anoth

2020-04-24 16:27发布

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?

1条回答
SAY GOODBYE
2楼-- · 2020-04-24 17:08

Declare an @property (nonatomic, retain) NSDate *displayDate; (or strong instead of retain when using ARC) on your TableViewController (dont forget to synthesize). The first view can then set the property of the TableViewController, for example:

MyTableViewController *mtvc = [[MyTableViewController alloc] initWithStyle:UITableViewStyleGrouped];
mtvc.displayDate = selectedDate;
...

You can then access the date from within your TableViewController using self.displayDate, for example in your titleForHeaderInSection.

查看更多
登录 后发表回答