summaryrefslogtreecommitdiff
path: root/SmartDeviceLinkTests/TestHapticRectViewController.m
blob: 2dd346429e9fc8d7d0f04ac40cd288a91122a1e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//
//  TestHapticRectViewController.m
//  SmartDeviceLinkTests
//
//  Created by Nicole on 9/1/20.
//  Copyright © 2020 smartdevicelink. All rights reserved.
//

#import "TestHapticRectViewController.h"

@interface TestHapticRectViewController ()

@end

@implementation TestHapticRectViewController

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-implementations"
- (UIView *)preferredFocusedView {
    return (UIView *)self.preferredFocusEnvironments.firstObject;
}
#pragma clang diagnostic pop

/// Return the subviews sorted by their tag values in acending order
- (NSArray<id<UIFocusEnvironment>> *)preferredFocusEnvironments {
    NSArray<UIView *> *subViews = self.view.subviews;

    NSArray *preferredFocusViews;
    preferredFocusViews = [subViews sortedArrayUsingComparator:^NSComparisonResult(id a, id b) {
        NSNumber *first = [NSNumber numberWithLong:[(UIView*)a tag]];
        NSNumber *second = [NSNumber numberWithLong:[(UIView*)b tag]];
        return [first compare:second];
    }];

    return preferredFocusViews;
}

@end