UIPickerView (FlipsideViewController) 在 MainViewController 中显示值

发布于 2024-12-11 22:13:07 字数 1118 浏览 3 评论 0原文

使用 MainViewController 类中的 FlipsideViewControllerDidFinish 方法,我可以显示子视图 FlipsideViewController 上的各种控件的值。例如,通过执行以下操作来创建 UIDatePicker:

NSDateFormatter *formatFromDate = [[NSDateFormatter alloc] init];
[formatFromDate setDateFormat:@"yyyy-MM-dd"];

NSDateFormatter *formatToDate = [[NSDateFormatter alloc] init];
[formatToDate setDateFormat:@"yyyy-MM-dd"];

NSString *fromDateSelected = [NSString stringWithFormat:@"%@",[formatFromDate stringFromDate:controller.fromDate.date]];
NSString *toDateSelected = [NSString stringWithFormat:@"%@",[formatToDate stringFromDate:controller.toDate.date]];

lblFromDate.text = fromDateSelected;
lblToDate.text = toDateSelected;

我试图获取 UIPickerView 的值以显示在 MainViewController 上。我可以使用以下事件方法在 FlipsideViewController 上显示该值:

- (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {

    customDateSelected = [customDates objectAtIndex:row];
    NSLog(@"Selected Date: %@. Index of selected Date: %i", customDateSelected, row);
}

只是不知道如何在 MainViewController 中显示该值。

Using the flipsideViewControllerDidFinish method in my MainViewController class, I can display the values of various controls that are on my subview FlipsideViewController. e.g. a UIDatePicker by doing the following:

NSDateFormatter *formatFromDate = [[NSDateFormatter alloc] init];
[formatFromDate setDateFormat:@"yyyy-MM-dd"];

NSDateFormatter *formatToDate = [[NSDateFormatter alloc] init];
[formatToDate setDateFormat:@"yyyy-MM-dd"];

NSString *fromDateSelected = [NSString stringWithFormat:@"%@",[formatFromDate stringFromDate:controller.fromDate.date]];
NSString *toDateSelected = [NSString stringWithFormat:@"%@",[formatToDate stringFromDate:controller.toDate.date]];

lblFromDate.text = fromDateSelected;
lblToDate.text = toDateSelected;

I am trying to get the value of a UIPickerView to display on the MainViewController. I can display the value on the FlipsideViewController by using the following event method:

- (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {

    customDateSelected = [customDates objectAtIndex:row];
    NSLog(@"Selected Date: %@. Index of selected Date: %i", customDateSelected, row);
}

Just don't know how to display that value in the MainViewController.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文