moving a bar with UIScrollViewKeyboardDismissModeInteractive(使用 UIScrollViewKeyboardDismissModeInteractive 移动条形图)
问题描述
我有一个固定在键盘顶部的文本字段.我不能使用 inputAccessoryView 因为它总是显示.我能够观察到键盘隐藏/显示通知以使用键盘上下移动,但这似乎不适用于 UIScrollViewKeyboardDismissModeInteractive.有没有办法获得关于键盘位置的持续反馈以同步动画?
I have a text field that I anchor to the top of the keyboard. I can't use inputAccessoryView since it's always shown. I'm able to observe keyboard hidden/shown notifications to move it up and down with the keyboard, but this doesn't appear to work with UIScrollViewKeyboardDismissModeInteractive. Is there a way to get constant feedback on the position of the keyboard to sync the animation?
推荐答案
看起来这在 iOS 8 中不起作用,伙计们——抱歉!我也在寻找新的解决方案
我通过创建一个不可见的 inputAccessoryView 解决了这个问题.
I solved this by creating a non-visible inputAccessoryView.
textView.inputAccessoryView = [[MJXObservingInputAccessoryView alloc] init];
accessoryView 观察其父视图的框架并发布一个您可以匹配的通知.
The accessoryView observes its superview's frame and posts out a notification you can match.
static NSString * const MJXObservingInputAccessoryViewSuperviewFrameDidChangeNotification = @"MJXObservingInputAccessoryViewSuperviewFrameDidChangeNotification";
@interface MJXObservingInputAccessoryView : UIView @end
@implementation MJXObservingInputAccessoryView
- (void)willMoveToSuperview:(UIView *)newSuperview
{
if (self.superview)
{
[self.superview removeObserver:self
forKeyPath:@"frame"];
}
[newSuperview addObserver:self
forKeyPath:@"frame"
options:0
context:NULL];
[super willMoveToSuperview:newSuperview];
}
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context
{
if (object == self.superview && [keyPath isEqualToString:@"frame"])
{
[[NSNotificationCenter defaultCenter] postNotificationName:MJXObservingInputAccessoryViewSuperviewFrameDidChangeNotification
object:self];
}
}
@end
这篇关于使用 UIScrollViewKeyboardDismissModeInteractive 移动条形图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 UIScrollViewKeyboardDismissModeInteractive 移动条形图


基础教程推荐
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01