Skip to content

Instantly share code, notes, and snippets.

@zrxq
Created May 29, 2013 13:37
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save zrxq/5670311 to your computer and use it in GitHub Desktop.
Save zrxq/5670311 to your computer and use it in GitHub Desktop.
UITableViewCell + UIDatePicker
#import <UIKit/UIKit.h>
@interface DatePickingCell : UITableViewCell
@property (strong, nonatomic) UIDatePicker *datePicker;
@end
#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