2011-11-24 73 views
1

我有两个视图,第一个是日历,第二个是UIView,有tableView; 我想从firstView中显示选定的日期。管理得到我的secondView的ViewDidLoad方法中的选定日期。从另一个ViewController获取NSDate到titleForHeaderInSection

如何将我的NSDate添加到我的- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section方法中?

+0

我认为你需要在nextview中创建变量并将其设置为表视图的标题。 –

回答

1

在TableViewController上声明@property (nonatomic, retain) NSDate *displayDate;(或strong而不是retain,当使用ARC时)(不要忘记合成)。然后第一个视图可以设置TableViewController的特性,例如:

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

您可以使用self.displayDate再访问日期之前,您TableViewController内,例如在你的titleForHeaderInSection

+0

但我的ViewController中,我有表查看其UIView控制器 –

+0

基本上是同样的事情。某处你必须有一个'UITableViewDataSource',那个类获取属性并获得NSDate。 –

+0

'@interface secondView:UIViewController '这是我的第二个视图的标题行Controller –

相关问题