Iphone 将NSDate从另一个ViewController获取到titleForHeaderInSection中
我有两个视图,第一个是日历视图,第二个是带有Iphone 将NSDate从另一个ViewController获取到titleForHeaderInSection中,iphone,uitableview,uiviewcontroller,ios5,tableview,Iphone,Uitableview,Uiviewcontroller,Ios5,Tableview,我有两个视图,第一个是日历视图,第二个是带有表视图的UIView; 我正在尝试从firstView显示所选日期。设法在我的第二个视图的ViewDidLoad方法中获取所选日期 如何将我的NSDate添加到我的-(NSString*)tableView:(UITableView*)tableView titleForHeaderInSection:(NSInteger)section方法?声明一个@属性(非原子,保留)NSDate*displayDate(或者使用ARC时使用strong而不是re
表视图的UIView
;
我正在尝试从firstView显示所选日期。设法在我的第二个视图的ViewDidLoad
方法中获取所选日期
如何将我的
NSDate
添加到我的-(NSString*)tableView:(UITableView*)tableView titleForHeaderInSection:(NSInteger)section
方法?声明一个@属性(非原子,保留)NSDate*displayDate在TableViewController上进行编码>(或者使用ARC时使用strong
而不是retain
)(别忘了合成)。然后,第一个视图可以设置TableViewController的属性,例如:
MyTableViewController *mtvc = [[MyTableViewController alloc] initWithStyle:UITableViewStyleGrouped];
mtvc.displayDate = selectedDate;
...
然后,您可以使用self.displayDate
从TableViewController中访问日期,例如,在titleForHeaderInSection
中声明一个@属性(非原子,保留)NSDate*displayDate在TableViewController上进行编码>(或者使用ARC时使用strong
而不是retain
)(别忘了合成)。然后,第一个视图可以设置TableViewController的属性,例如:
MyTableViewController *mtvc = [[MyTableViewController alloc] initWithStyle:UITableViewStyleGrouped];
mtvc.displayDate = selectedDate;
...
然后,您可以使用self.displayDate
,从TableViewController中访问日期,例如,在您的标题forheaderin部分
中,我认为您需要在nextview中创建变量并将其设置为表视图的标题。我认为您需要在nextview中创建变量并将其设置为表视图的标题。某个地方必须有一个UITableViewDataSource
,该类获取属性并获取传递的NSDate。@interface secondView:UIViewController
这是我的第二个视图控制器的标题行,因此视图控制器是数据源。然后,您也可以在UIViewController中创建属性。无论您的第一个视图在何处创建了secondView
的实例,请填写displayDate
属性,如代码所示。您的secondView
现在可以在类中的任何位置使用self.displayDate
访问日期。在secondView
的dealloc
方法中放置一个self.displayDate=nil
,以避免内存泄漏。但我的视图控制器(其中有表视图)是UIView控制器,基本上是一样的。某个地方必须有一个UITableViewDataSource
,该类获取属性并获取传递的NSDate。@interface secondView:UIViewController
这是我的第二个视图控制器的标题行,因此视图控制器是数据源。然后,您也可以在UIViewController中创建属性。无论您的第一个视图在何处创建了secondView
的实例,请填写displayDate
属性,如代码所示。您的secondView
现在可以在类中的任何位置使用self.displayDate
访问日期。在secondView
的dealloc
方法中放置一个self.displayDate=nil
,以避免内存泄漏。