UILabel nie wyświetla inputView
Używałbym UILabel, aby umożliwić użytkownikom wybranie daty za pomocą UIDatePicker.
Aby to zrobić, utworzyłem podklasę UILabel nadpisującą inputView i właściwości inputAccessoryView, dzięki czemu można je zapisać; Zaimplementowałem także - (BOOL) canBecomeFirstResponder, a metody - (BOOL) isUserInteractionEnabled zwracają YES dla obu. Następnie przypisałem instancję UIDatePIcker do właściwości inputView.
W tym momencie spodziewałem się, że po puknięciu etykiety powinien pojawić się UIDatePicker, ale nic się nie dzieje.
Jakaś pomoc?
To jest kod:
YPInteractiveUILabel.h
@interface YPInteractiveUILabel : UILabel
@property (readwrite) UIView *inputView;
@property (readwrite) UIView *inputAccessoryView;
- (BOOL) canBecomeFirstResponder;
- (BOOL) isUserInteractionEnabled;
@end
YPInteractiveUILabel.h
#import "YPInteractiveUILabel.h"
@implementation YPInteractiveUILabel
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self)
{
UIDatePicker *datePicker = [[UIDatePicker alloc] init];
[self setInputView:datePicker];
}
return self;
}
- (BOOL)isUserInteractionEnabled
{
return YES;
}
- (BOOL)canBecomeFirstResponder
{
return YES;
}
@end