Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save steventroughtonsmith/567f362644ed351bea013574fb5d8495 to your computer and use it in GitHub Desktop.
Save steventroughtonsmith/567f362644ed351bea013574fb5d8495 to your computer and use it in GitHub Desktop.
UICollectionView _shouldBecomeFocusedOnSelection Mac Catalyst
//
// 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