Skip to content

Commit

Permalink
Merge pull request #1157 from dostrander/dostrander/1146-fix-date-pic…
Browse files Browse the repository at this point in the history
…ker-description

Fixes issue #1146 where date pickers print over 12k lines of text
  • Loading branch information
dostrander committed Jul 14, 2020
2 parents 1ddc43c + 34d0241 commit 0ba0e9e
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion Additions/UIView-Debugging.m
Expand Up @@ -46,9 +46,19 @@ - (void)printViewHierarchyWithIndentation:(int)indent {
if([self isKindOfClass:[UIControl class]]) {
[self printControlState];
}

if([self isKindOfClass:[UIDatePicker class]]) {
[self printDatePickerState];
}

printf("\n");

[self printAccessibilityElementsWithIndentation:indent];

// We do not want to print the view heirarchy under this class as it is too large and not helpful.
if([self isKindOfClass:[NSClassFromString(@"_UIDatePickerView") class]]) {
return;
}

for (UIView *subview in self.subviews) {
[subview printViewHierarchyWithIndentation:indent+1];
Expand Down Expand Up @@ -91,6 +101,36 @@ - (void)printControlState {
ctrl.highlighted ? printf(" (highlighted)") : printf(" (not highlighted)");
}

- (void)printDatePickerState {
UIDatePicker *datePicker = (UIDatePicker *)self;
printf(" (date range:");
datePicker.minimumDate ? printf(" %s", datePicker.minimumDate.description.UTF8String) : printf(" no minimum");
printf(" -");
datePicker.maximumDate ? printf(" %s", datePicker.minimumDate.description.UTF8String) : printf(" no maximum");
printf(")");
printf(" (mode:");

switch (datePicker.datePickerMode) {
case UIDatePickerModeTime:
printf(" UIDatePickerModeTime");
break;

case UIDatePickerModeDate:
printf(" UIDatePickerModeDate");
break;

case UIDatePickerModeDateAndTime:
printf(" UIDatePickerModeDateAndTime");
break;

case UIDatePickerModeCountDownTimer:
printf(" UIDatePickerModeCountDownTimer");
break;
}
printf(")");
printf(" (minute interval: %li)", datePicker.minuteInterval);
}

- (void)printAccessibilityElementsWithIndentation:(int)indent {
NSInteger numOfAccElements = self.accessibilityElementCount;
if(numOfAccElements != NSNotFound) {
Expand Down

0 comments on commit 0ba0e9e

Please sign in to comment.