Created
May 29, 2013 13:37
-
-
Save zrxq/5670311 to your computer and use it in GitHub Desktop.
UITableViewCell + UIDatePicker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
@interface DatePickingCell : UITableViewCell | |
@property (strong, nonatomic) UIDatePicker *datePicker; | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "DatePickingCell.h" | |
@implementation DatePickingCell | |
- (UIDatePicker *)datePicker { | |
if (_datePicker) | |
return _datePicker; | |
_datePicker = [[UIDatePicker alloc] init]; | |
return _datePicker; | |
} | |
- (UIView *)inputView { | |
return self.datePicker; | |
} | |
- (BOOL)canBecomeFirstResponder { | |
return YES; | |
} | |
- (void)setSelected:(BOOL)selected animated:(BOOL)animated | |
{ | |
[super setSelected:selected animated:animated]; | |
if (selected) | |
[self becomeFirstResponder]; | |
else | |
[self resignFirstResponder]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment