将数据传递给 secondaryViewController

发布于 2024-12-18 11:46:09 字数 462 浏览 4 评论 0原文

尝试从我以前的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

白龙吟 2024-12-25 11:46:10

将日期属性添加到第二个视图控制器,并在创建实例时对其进行适当设置...

Add a date property to your secondViewController, and set it appropriately when you create the instance...

成熟稳重的好男人 2024-12-25 11:46:10

目前还不清楚第一个或第二个 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

耳根太软 2024-12-25 11:46:10

视图控制器之间交换数据的方式有很多种,把它们当成对象就可以了。

  1. 第一个控制器保存第二个控制器的引用,并使用变量和方法传输数据,
  2. 使用委托,
  3. 使用通知

等。

There are many ways to exchange data between view controllers, just take them as objects.

  1. first controller hold a ref of the second controller, and transfer data using variables and methods
  2. use delegate,
  3. use notification

etc.

慈悲佛祖 2024-12-25 11:46:10

我可以看到您正在将 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文