Created
April 22, 2022 15:06
-
-
Save steventroughtonsmith/567f362644ed351bea013574fb5d8495 to your computer and use it in GitHub Desktop.
UICollectionView _shouldBecomeFocusedOnSelection Mac Catalyst
This file contains 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
// | |
// MRDSwizzleController.swift | |
// MobileRadio | |
// | |
// Created by Steven Troughton-Smith on 22/12/2021. | |
// Copyright © 2021 High Caffeine Content. All rights reserved. | |
// | |
import UIKit | |
extension NSObject { | |
@objc func MRD_shouldBecomeFocusedOnSelection() -> Bool { | |
return true | |
} | |
} | |
class MRDSwizzleController: NSObject { | |
override init() { | |
super.init() | |
do { | |
let m1 = class_getInstanceMethod(NSClassFromString("UICollectionView"), NSSelectorFromString("_shouldBecomeFocusedOnSelection")) | |
let m2 = class_getInstanceMethod(NSClassFromString("UICollectionView"), NSSelectorFromString("MRD_shouldBecomeFocusedOnSelection")) | |
if let m1 = m1, let m2 = m2 { | |
method_exchangeImplementations(m1, m2) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment