Skip to content
Open
2 changes: 1 addition & 1 deletion extras/QPickerTableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ @implementation QPickerTableViewCell

- (QPickerTableViewCell *)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
if ((self = [self initWithStyle:style reuseIdentifier:reuseIdentifier]))
if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]))
{
[self createSubviews];
self.selectionStyle = UITableViewCellSelectionStyleBlue;
Expand Down
3 changes: 2 additions & 1 deletion quickdialog/QDateInlineTableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ - (void)prepareDateTimePicker:(QDateTimeInlineElement *)element
if (!self.pickerView)
self.pickerView = [[UIDatePicker alloc] init];

self.pickerView.timeZone = [NSTimeZone localTimeZone];
self.pickerView.timeZone = element.timezone;
[self.pickerView sizeToFit];
self.pickerView.datePickerMode = element.mode;
self.pickerView.maximumDate = element.maximumDate;
Expand All @@ -68,6 +68,7 @@ - (void) dateChanged:(id)sender{
- (void)prepareForElement:(QDateTimeInlineElement *)element inTableView:(QuickDialogTableView *)tableView {

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.timeZone = element.timezone;

self.element = element;
if (element.customDateFormat!=nil){
Expand Down
5 changes: 5 additions & 0 deletions quickdialog/QDateTimeInlineElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
@interface QDateTimeInlineElement : QEntryElement {
NSDate * _dateValue;
@private
NSTimeZone *_timezone;
UIDatePickerMode _mode;
NSInteger _minuteInterval;
BOOL _centerLabel;
Expand All @@ -29,6 +30,8 @@

@property (assign) UIDatePickerMode mode;

@property (nonatomic, strong) NSTimeZone *timezone;

@property (assign) NSInteger minuteInterval;

@property(nonatomic) BOOL centerLabel;
Expand All @@ -43,4 +46,6 @@

- (QDateTimeInlineElement *)initWithTitle:(NSString *)string date:(NSDate *)date andMode:(UIDatePickerMode)mode;

- (QDateTimeInlineElement *)initWithTitle:(NSString *)string date:(NSDate *)date timezone:(NSTimeZone *)timezone andMode:(UIDatePickerMode)mode;

@end
17 changes: 12 additions & 5 deletions quickdialog/QDateTimeInlineElement.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ @implementation QDateTimeInlineElement {
}

@synthesize mode = _mode;
@synthesize timezone = _timezone;
@synthesize centerLabel = _centerLabel;
@synthesize maximumDate = _maximumDate;
@synthesize minimumDate = _minimumDate;
Expand All @@ -46,15 +47,24 @@ - (QDateTimeInlineElement *)initWithKey:(NSString *)key {
return self;
}

- (QDateTimeInlineElement *)initWithTitle:(NSString *)string date:(NSDate *)date andMode:(UIDatePickerMode)mode{
- (QDateTimeInlineElement *)initWithTitle:(NSString *)string date:(NSDate *)date timezone:(NSTimeZone *)timezone andMode:(UIDatePickerMode)mode {
self = [super initWithTitle:string Value:[date description]];
if (self!=nil){
_dateValue = date;
_mode = mode;
_timezone = timezone;
}
return self;

}

- (QDateTimeInlineElement *)initWithTitle:(NSString *)string date:(NSDate *)date andMode:(UIDatePickerMode)mode{
return [self initWithTitle:string date:date timezone:nil andMode:mode];
}

- (QDateTimeInlineElement *)initWithDate:(NSDate *)date andMode:(UIDatePickerMode)mode{
return [self initWithTitle:nil date:date andMode:mode];
}

- (void)setTicksValue:(NSNumber *)ticks {
if (ticks!=nil)
Expand All @@ -69,6 +79,7 @@ - (NSDate *)dateValue
{
if (self.mode == UIDatePickerModeDate) {
NSCalendar *gregorian = [[NSCalendar alloc]initWithCalendarIdentifier:NSGregorianCalendar];
gregorian.timeZone = _timezone;
NSDateComponents *dateComponents = [gregorian components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit) fromDate:_dateValue];
_dateValue = [gregorian dateFromComponents:dateComponents];
}
Expand All @@ -79,10 +90,6 @@ -(NSNumber *)ticksValue {
return [NSNumber numberWithDouble:[self.dateValue timeIntervalSince1970]];
}

- (QDateTimeInlineElement *)initWithDate:(NSDate *)date andMode:(UIDatePickerMode)mode{
return [self initWithTitle:nil date:date andMode:mode];
}

- (UITableViewCell *)getCellForTableView:(QuickDialogTableView *)tableView controller:(QuickDialogController *)controller {

QTableViewCell *cell= self.showPickerInCell ? [self getInlineCell:tableView] : [self getEntryCell:tableView];
Expand Down
5 changes: 4 additions & 1 deletion quickdialog/QEntryTableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ -(UIToolbar *)createActionBar {
_prevNext = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:NSLocalizedString(@"Previous", @""), NSLocalizedString(@"Next", @""), nil]];
_prevNext.momentary = YES;
_prevNext.segmentedControlStyle = UISegmentedControlStyleBar;
_prevNext.tintColor = actionBar.tintColor;
[_prevNext addTarget:self action:@selector(handleActionBarPreviousNext:) forControlEvents:UIControlEventValueChanged];
UIBarButtonItem *prevNextWrapper = [[UIBarButtonItem alloc] initWithCustomView:_prevNext];
UIBarButtonItem *flexible = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
Expand Down Expand Up @@ -143,6 +142,10 @@ - (void)prepareForElement:(QEntryElement *)element inTableView:(QuickDialogTable
_textField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
_textField.textAlignment = _entryElement.appearance.entryAlignment;

// workaround for UITextField bug: if the user is using a bigger system font, a long text won't scroll
_textField.adjustsFontSizeToFitWidth = YES;
_textField.minimumFontSize = 20.0f;

_textField.returnKeyType = _entryElement.returnKeyType;
_textField.enablesReturnKeyAutomatically = _entryElement.enablesReturnKeyAutomatically;

Expand Down
2 changes: 1 addition & 1 deletion quickdialog/QMultilineElement.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ - (void)selected:(QuickDialogTableView *)tableView controller:(QuickDialogContro
__weak QMultilineTextViewController *weakTextController = textController;
textController.willDisappearCallback = ^ {
weakSelf.textValue = weakTextController.textView.text;
[[tableView cellForElement:weakSelf] setNeedsDisplay];
[tableView reloadCellForElements:weakSelf, nil];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
};
[controller displayViewController:textController withPresentationMode:self.presentationMode];
Expand Down
9 changes: 1 addition & 8 deletions quickdialog/QMultilineTextViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,6 @@ - (void)loadView
self.view = _textView;
}

- (void)viewDidLoad
{
[super viewDidLoad];
if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
self.edgesForExtendedLayout = UIRectEdgeNone;
}

- (void)viewWillAppear:(BOOL)animated
{
_viewOnScreen = YES;
Expand Down Expand Up @@ -102,7 +95,7 @@ - (void) resizeForKeyboard:(NSNotification*)aNotification {
[UIView animateWithDuration:animationDuration delay:0 options:animationCurve
animations:^{
CGRect keyboardFrame = [self.view convertRect:keyboardEndFrame toView:nil];
_textView.contentInset = UIEdgeInsetsMake(0.0, 0.0, up ? keyboardFrame.size.height : 0, 0.0);
_textView.contentInset = UIEdgeInsetsMake(_textView.contentInset.top, _textView.contentInset.left, up ? keyboardFrame.size.height : 0, _textView.contentInset.right);
}
completion:NULL];
}
Expand Down