UIPickerView (FlipsideViewController) 在 MainViewController 中显示值
使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论