- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我有一个 UIKeyboardWillShowNotification
和 UIKeyboardWillHideNotification
的观察者。
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
一切正常,除非它在 viewController 当前不可见时有效。
我尝试与 self.navigationcontroller.topViewController
进行比较,但是当我有一个模态视图时,这不起作用,因为 topViewController
是模态下方的 View Controller 。
最佳答案
如果您正在使用 UIViewController
,当 View 在 viewWillAppear:
中可见时,您可以为键盘通知注册您的实例,然后在 View 隐藏在其中时取消注册viewWillDisappear:
这样,当 View 不可见时您将不会收到通知。
希望这对您有所帮助!
关于ios - KeyboardWillShowNotification,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16966443/
我有一个 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 的顶部。我还将代码添加到了似乎导致问题的文本字段的创建中。
我是一名优秀的程序员,十分优秀!