1
다음 구독을 신속하게 처리하고 있습니다. 키보드를 언제 위로 움직이면되는지 알 필요가 있습니다. 컴파일되고 예상대로 작동하지만이 경고를 제거하는 방법을 알지 못합니다. 어떤 제안을 사전에NSNotifications에 가입 할 때 Objective C 선택기를 인수로 사용하는 방법은 무엇입니까?
// Subscribing class to recieve the notification
func subscribeToKeyboardNotifications() {
NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWillShow", name: UIKeyboardWillShowNotification, object: nil)
}
// Shifting view's frame up
func keyboardWillShow(notification: NSNotification) {
view.frame.origin.y -= getKeyboardHeight(notification)
}
// Getting keyboard height
func getKeyboardHeight(notification: NSNotification) -> CGFloat {
let userInfo = notification.userInfo
let keyboardSize = userInfo![UIKeyboardFrameEndUserInfoKey] as! NSValue // of CGRect
return keyboardSize.CGRectValue().height
}
감사합니다 "목표 - C의 selector'keyboardWillShow '로 선언있는 방법!"
하십시오이이 답을 확인 http://stackoverflow.com/questions/36366116/no-method-declared-with-objective-c-selector-for-notification-uikeyboardwillshow – Sandy