- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在使用 UIKeyboardWillShowNotification
来检测用户何时选择文本字段以及何时打开键盘。在 ios 8 和旧版本的 iOS 中它工作正常但今天我升级到 iOS 9 和 xCode 7。问题是在 iOS 现在选择每个文本字段后调用通知(而在 ios 8 中仅在选择第一个文本字段后调用) .
我对此进行了搜索,并找到了类似 Why is UIKeyboardWillShowNotification called every time another TextField is selected? 的帖子
但这与 iOS 9 无关(实际上在 iOS8 中一切都是正确的,通过升级我看到了问题)而且我也没有使用 inputAccessoryViews。
最佳答案
同样的问题。我的 View Controller 中有一些 UITexfield
,当我使用 becomeFirstResponder
方法以编程方式为另一个文本字段留下一个文本字段时,再次调用 UIKeyboardWillShowNotification
。即使键盘不再隐藏和显示。但是,不会调用 UIKeyboardWillHideNotification
。
我不知道为什么这个问题会出现在 iOS9 中,但我可以给你一个解决方法。我做了什么:我在我的 View Controller 中创建了一个 BOOL 属性:
@property (assign, nonatomic) BOOL keyboardIsShown;
在我的键盘观察者方法中:
- (void)keyboardWillHideNotification:(NSNotification *)notification {
self.keyboardIsShown = NO;
//rest of code
}
- (void)keyboardWillShowNotification:(NSNotification *)notification {
if(self.keyboardIsShown) {
return;
}
self.keyboardIsShown = YES;
//some code
}
如果有人有更清晰的解决方案来避免在 iOS9 中调用 becomeFirstResponder
时在另一个 UITextField
上多次调用 UIKeyboardWillShowNotification
,我会采取它!
关于ios - KeyboardWillShowNotification 调用两次 ios 9,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32860151/
我有一个 UIKeyboardWillShowNotification 和 UIKeyboardWillHideNotification 的观察者。 [[NSNotificationCenter de
我正在使用 keyboardWasShown 和 keyboardWillBeHidden 通知来滑动 View 以获取可见的 TextView 。 我有一个带有六个选项卡的 UITabBar 应用程
这是操作顺序的问题 NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; [nc addObserver:self
我有一个带有文本字段的自定义 UITableViewCell。单元格的文本字段设置为调用委托(delegate)函数。里面 -(BOOL)textFieldShouldReturn:(UIText
我已订阅 keyboardWillShowNotification 和 keyboardWillHideNotification 以在我的 UI 中移动。我注意到,当我通过点击“Go”按钮关闭键盘时,
我需要在键盘可见后立即向上移动 UIView。但我现在面临的问题是,当我使用自定义键盘(例如 SwiftKey)时,我的 UIKeyboardWillShowNotification 被调用了三次,这
这个问题在这里已经有了答案: can't get correct value of keyboard height in iOS8 (10 个答案) 关闭 8 年前。 我的 UI 在显示键盘时需要进
我正在 viewdidload 上创建通知UIKeyboardWillShowNotification 并在 上删除它 View 将消失 . 当键盘出现在屏幕上并按预期调用一次通知时,我锁定了屏幕。通
我不知道出了什么问题。我的导航栏中有 2 个右侧按钮,当键盘打开时,我需要 A 和 B 按钮,当键盘关闭时,我需要 A 和 C,或者可能只是 C。我这样做了。我使用 UIKeyboardWillSho
当调用键盘时,我使用 UIKeyboardWillShowNotification 上下 ScrollView 。这在大多数情况下都可以正常工作。但是,键盘有一个完成按钮,可以生成 UIAlert。没
我有一个带有“安全文本输入”的表单,我想在键盘打开时向上滚动我的 View 。 我正在收听 UIKeyboardWillShowNotification 但是当焦点位于密码字段时,会再次发送此通知并且
我会在键盘出现和消失时创建通知。 override func viewDidLoad() { super.viewDidLoad() // Creates notification w
我想在不使用可用的键盘通知的情况下获取键盘的大小。原因是我在 View 上有多个文本字段,我不需要为它们的所有 调整 View 的大小,正如我在几乎每个示例中看到的那样。我只需要调整一些文本字段/ V
我有一个非常奇怪的问题,当我按回车键时会发生这种情况,并且只有当我第一次按回车键时才会发生这种情况,每次下一次它都会按预期工作。 我有一个简单的类来管理键盘,它接受我拒绝委托(delegate)给我的
我正在使用日期选择器作为文本字段的输入 View 。在 View 中将出现我已添加 UIKeyboardWillShowNotification。 我的问题是,当要查看日期选择器时,它也会出现 Key
我正在使用 UIKeyboardWillShowNotification 来检测用户何时选择文本字段以及何时打开键盘。在 ios 8 和旧版本的 iOS 中它工作正常但今天我升级到 iOS 9 和 x
初始化部分: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:)
我正在使用 UIKeyboardWillShowNotification 和 UIKeyboardWillHideNotification 处理键盘框架更改。当用户通过按下“globe”键打开、隐藏键
我在 IOS 7 和 IOS 8 设备上运行相同的代码但结果不同 给定一个包含两个文本字段的屏幕 在 IOS 7 中,如果我触摸第一个字段 keyboardWillShow 会被调用,但如果我在键盘已
在我标题为handleKeyboardWillShow的函数上,我的输入文本字段的移动速度高于预期。我的目的是将文本字段固定到键盘 View 的顶部。我还将代码添加到了似乎导致问题的文本字段的创建中。
我是一名优秀的程序员,十分优秀!