1
0
mirror of https://github.com/mastodon/mastodon-ios.git synced 2024-12-17 19:30:10 +01:00

fix: workaround paste crash on iOS 14.x issue

This commit is contained in:
CMK 2022-12-01 15:29:56 +08:00
parent 7aed050ded
commit fd9a253fac

View File

@ -13,17 +13,21 @@ extension MetaTextView {
public override func paste(_ sender: Any?) {
super.paste(sender)
var nextResponder = self.next;
// Force the event to bubble through ALL responders
// This is a workaround as somewhere down the chain the paste event gets eaten
while (nextResponder != nil) {
if let nextResponder = nextResponder {
if (nextResponder.responds(to: #selector(UIResponderStandardEditActions.paste(_:)))) {
nextResponder.perform(#selector(UIResponderStandardEditActions.paste(_:)), with: sender)
// fix #660
// https://github.com/mastodon/mastodon-ios/issues/660
if #available(iOS 15.0, *) {
var nextResponder = self.next;
// Force the event to bubble through ALL responders
// This is a workaround as somewhere down the chain the paste event gets eaten
while (nextResponder != nil) {
if let nextResponder = nextResponder {
if (nextResponder.responds(to: #selector(UIResponderStandardEditActions.paste(_:)))) {
nextResponder.perform(#selector(UIResponderStandardEditActions.paste(_:)), with: sender)
}
}
nextResponder = nextResponder?.next;
}
nextResponder = nextResponder?.next;
}
} // end if
}
}