【发布时间】:2023-04-04 13:56:01
【问题描述】:
我在 xcode 5.1.1 中构建的项目代码 (cmnd + b) 使用模拟器 iphone 5 ios 7.1 运行 (cmnd + r) 产生以下结果
在 xcode 6.1.1 中构建的相同代码 (cmnd + b) 使用模拟器 iphone 5 ios 7.1 运行 (cmnd + r) 产生以下结果
- 使用模拟器 iphone 5 ios 8.1 在 xcode 6.1.1 中运行看起来不错(就像 xcode 5.1.1 中的第一张图片)
有什么想法吗?
这是显示键盘的代码:
- (void)showKeyboard:(NSNotification*)notification
{
NSValue *keyboardEndFrameValue = [[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey];
CGRect keyboardEndFrame = [keyboardEndFrameValue CGRectValue];
NSNumber *animationDurationNumber = [[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey];
NSTimeInterval animationDuration = [animationDurationNumber doubleValue];
NSNumber *animationCurveNumber = [[notification userInfo] objectForKey:UIKeyboardAnimationCurveUserInfoKey];
UIViewAnimationCurve animationCurve = [animationCurveNumber intValue];
UIViewAnimationOptions animationOptions = animationCurve << 16;
int searchBarYPadding = 60;
if ([[UIDevice currentDevice].systemVersion floatValue] >= 7.0f)
{
searchBarYPadding = 42;
}
[UIView animateWithDuration:animationDuration
delay:0.0
options:animationOptions
animations:^{
CGRect textFieldFrame = self.addressSearchBar.frame;
textFieldFrame.origin.y = keyboardEndFrame.origin.y - searchBarYPadding;
self.addressSearchBar.frame = textFieldFrame;
}
completion:^(BOOL finished) {isKeyboardDisplayed = YES;}];
}
【问题讨论】:
标签: ios objective-c xcode keyboard