-
-
Save sumate-sdk/3f1d8745248ef0f8fa4f965db9e54a66 to your computer and use it in GitHub Desktop.
Get the current first responder
This file contains hidden or 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
// | |
// UIResponder.swift | |
// | |
// Created by Groom on 23/03/2015. | |
// Copyright (c) 2015 Stephen Groom. All rights reserved. | |
// | |
import UIKit | |
extension UIResponder { | |
//Class var not supported in 1.0 | |
private struct CurrentFirstResponder { | |
weak static var currentFirstResponder: UIResponder? | |
} | |
private class var currentFirstResponder: UIResponder? { | |
get { return CurrentFirstResponder.currentFirstResponder } | |
set(newValue) { CurrentFirstResponder.currentFirstResponder = newValue } | |
} | |
class func getCurrentFirstResponder() -> UIResponder? { | |
currentFirstResponder = nil | |
UIApplication.sharedApplication().sendAction("findFirstResponder", to: nil, from: nil, forEvent: nil) | |
return currentFirstResponder | |
} | |
func findFirstResponder() { | |
UIResponder.currentFirstResponder = self | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment