Set a property or something, like this...
// in the private extension
@property (nonatomic) BOOL flatDatePickerOpen;
Then do something like this...
- (IBAction)toggleFlatDatePicker {
if (self.flatDatPickerOpen) {
[self.flatDatePicker dismiss];
self.flatDatePickerOpen = NO;
} else {
[self.flatDatePicker show];
self.flatDatePickerOpen = YES;
}
}
You don't have to specify the sender part of the action either. If you're not using it then there's no need for it.
Alternatively, use a property on the flatDatePicker that tells you whether it is visible or not instead of the additional property.