简体   繁体   English

UIDatePicker:如果未更改任何值,如何调用函数?

[英]UIDatePicker: How to call a function if no value was changed?

I have a question concerning a UIDatePicker: 我有一个关于UIDatePicker的问题:

[datePicker addTarget:self action:@selector(datePickerValueChanged:) forControlEvents:UIControlEventValueChanged];

This will call my method "datePickerValueChanged:" but only if, well, a value got changed. 这将调用我的方法“ datePickerValueChanged:”,但前提是值被更改了。 But how can I call that method if nothing on the UIDatePicker was changed? 但是,如果UIDatePicker上的任何内容均未更改,如何调用该方法?

When do you want to call the method? 您什么时候要调用该方法? (or when do you want it to be called?) (或您希望何时调用它?)

If you keep a reference to your date picker object, you can always call the 'datePickerValueChanged' action method directly from within your controller object or any other object that has a reference to your controller object. 如果保留对日期选择器对象的引用,则始终可以直接从控制器对象或具有对控制器对象的引用的任何其他对象中直接调用“ datePickerValueChanged”操作方法。 You can also interrogate the date picker at any time if you have a handle to it, via its date property, to find out which date is showing. 如果您有日期处理程序的句柄,也可以通过其日期属性随时查询它,以找出显示的日期。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM