将数据传递给 secondaryViewController
尝试从我以前的 ViewController 发送一些数据。为了更清楚地尝试将 Si-Calendar 的选定日期发送到我的第二个视图。
我以这种方式将日历添加到我的视图中:
CalendarMonth *aCalendarView = [[CalendarMonth alloc] initWithFrame:CGRectMake(0, 0, 320, 324) logic:calendarLogic];
[aCalendarView selectButtonForDate:selectedDate];
[self.view addSubview:aCalendarView];
如何使用所选日期并将其发送到我的第二个视图控制器(一个我将在其中显示所选日期的 UIView)?
Trying to send some data form my previous ViewController. To be more clear trying to send the selected date of the Si-Calendar to my secondView.
I'm adding the Calendar to my view in this way:
CalendarMonth *aCalendarView = [[CalendarMonth alloc] initWithFrame:CGRectMake(0, 0, 320, 324) logic:calendarLogic];
[aCalendarView selectButtonForDate:selectedDate];
[self.view addSubview:aCalendarView];
How do I use selected date and send it to my secondViewController (a UIView in which I'll display the selected date)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
将日期属性添加到第二个视图控制器,并在创建实例时对其进行适当设置...
Add a date property to your secondViewController, and set it appropriately when you create the instance...
目前还不清楚第一个或第二个 viewController 是什么,但通常您可以使用委托来实现此目的。有关如何执行此操作的示例,请查看此答案< /a>
It is a bit unclear what the first or second viewController is, but in general you could use a delegate for this purpose. For an example on how to do this, take a look at this answer
视图控制器之间交换数据的方式有很多种,把它们当成对象就可以了。
等。
There are many ways to exchange data between view controllers, just take them as objects.
etc.
我可以看到您正在将 CalenderMonth 作为子视图添加到另一个视图。因此,如果您不释放它(直到您创建第二个视图控制器),您可以将日历月obj的selectedDate设置为第二个视图控制器的iVar。否则为 CalenderMonth 类创建一个委托。将第二个视图控制器设置为 CalenderMonth 的委托并执行必要的操作。
i can see that you are adding the CalenderMonth as the subview to another view. So if you dont release it (until u create the second view controller), you can set the selectedDate of the calender month obj to an iVar of second view controller. Else Create a delegate for CalenderMonth class. Set the second view controller as the delegate of the CalenderMonth and do the necessary.