Skip to content

Commit

Permalink
fix(ios): make programmatically focus work on iOS 13 (#1995)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile authored Sep 25, 2019
1 parent 8964a4a commit 069b248
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ios/Capacitor/Capacitor/CAPBridgeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ public class CAPBridgeViewController: UIViewController, CAPBridgeDelegate, WKScr
let oldSelector: Selector = sel_getUid("_startAssistingNode:userIsInteracting:blurPreviousNode:userObject:")
let newSelector: Selector = sel_getUid("_startAssistingNode:userIsInteracting:blurPreviousNode:changingActivityState:userObject:")
let newerSelector: Selector = sel_getUid("_elementDidFocus:userIsInteracting:blurPreviousNode:changingActivityState:userObject:")
let ios13Selector: Selector = sel_getUid("_elementDidFocus:userIsInteracting:blurPreviousNode:activityStateChanges:userObject:")

if let method = class_getInstanceMethod(wkc, oldSelector) {
let originalImp: IMP = method_getImplementation(method)
Expand All @@ -304,6 +305,10 @@ public class CAPBridgeViewController: UIViewController, CAPBridgeDelegate, WKScr
if let method = class_getInstanceMethod(wkc, newerSelector) {
self.swizzleAutofocusMethod(method, newerSelector, value)
}

if let method = class_getInstanceMethod(wkc, ios13Selector) {
self.swizzleAutofocusMethod(method, ios13Selector, value)
}
}

func swizzleAutofocusMethod(_ method: Method, _ selector: Selector, _ value: Bool) {
Expand Down

0 comments on commit 069b248

Please sign in to comment.