反应本机的不适在iOS中不起作用

时间:2019-05-07 10:04:50

标签: ios swift react-native

有可能在React Native中实现混乱。我已经在iOS本机中创建了一些令人毛骨悚然的功能,但是不适用于React Native。就像React Native中按钮的onPress事件无法正常工作一样。有人可以帮我一下,如何做到这一点。下面是按钮单击的本机部分的代码,如何为onPress的React Native按钮实现相同的功能。

    guard self == UIApplication.self else {
        return
    }

    let originalViewWillAppearSelector = #selector(self.sendAction(_:to:from:for:))
    let swizzledViewWillAppearSelector = #selector(self.interceptAction(_:to:from:for:))

    let originalViewWillAppearMethod = class_getInstanceMethod(self, originalViewWillAppearSelector)
    let swizzledViewWillAppearMethod = class_getInstanceMethod(self, swizzledViewWillAppearSelector)

    method_exchangeImplementations(originalViewWillAppearMethod!, swizzledViewWillAppearMethod!)

@objc func interceptAction(_ action: Selector,
                           to target: Any?,
                           from sender: Any?,
                           for event: UIEvent?) -> Bool {

    DispatchQueue.main.async {

    }
    return self.interceptAction(action, to: target, from: sender, for: event)
}

0 个答案:

没有答案