我在提出一个问题,即确定<条码>的内容。 当键盘已经可见时,见到代码>。 这里,我所谈的是什么(它并不涉及任何过于 ha的解决办法)。
您的观点控制者赞同< IDKey板WillShowNoification的想法是正确的,是这样做的最佳途径。 - 不要试图以任何其他方式计算主机大小,因为(a) 键盘大小可能无法预测,(b) 您不想冒用私人标本的风险。
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification
object:nil];
}
页: 1 显示代码>方法。 如果你重新使用<条码>,即刻板/条码<>——如我一样——你希望将由此产生的关键机体大小从<条码>中删除。 UIKey板FrameEndUserInfoKey key。
- (void)keyboardWillShow:(NSNotification *)notification {
NSDictionary *info = [notification userInfo];
NSTimeInterval duration = [[info objectForKey:UIKeyboardAnimationDurationUserInfoKey]
doubleValue];
CGSize keyboardSize = [[info objectForKey:UIKeyboardFrameEndUserInfoKey]
CGRectValue].size;
UIInterfaceOrientation orientation = [[UIApplication sharedApplication]
statusBarOrientation];
UIEdgeInsets insets = UIEdgeInsetsMake(0, 0, keyboardSize.height, 0);
// The gotcha is that the keyboard size as reported by
// UIKeyboardFrameEndUserInfoKey is always reported as if the device was in
// portrait mode. I ve had to work around that a little by setting the
// bottom edge to the keyboard s width.
if (UIInterfaceOrientationIsLandscape(orientation)) {
insets = UIEdgeInsetsMake(0, 0, keyboardSize.width, 0);
}
[UIView animateWithDuration:duration
delay:0
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
self.gridScrollView.contentInset = insets;
self.gridScrollView.scrollIndicatorInsets = insets;
} completion:nil];
}
希望能帮助你们——同样,利用通知实现你想要的东西是完全可能的和安全的。