我当前在键盘处于活动状态时更改了滚动视图大小.我还使用箭头允许用户快速移动到下一个文本字段.我的scrollRectToVisible在垂直方向上无法正常工作.它正确地水平移动.我的小数点有问题
2014-09-12 10:29:24.039 TS[1895:455658] Can't find keyplane that supports type 8 for keyboard iPhone-Portrait-DecimalPad; using 1425143906_Portrait_iPhone-Simple-Pad_Default
Run Code Online (Sandbox Code Playgroud)
我还介绍了以下代码.
- (void)keyboardDidShow:(NSNotification *)n {
// Find top of keyboard input view
CGRect keyboardRect = [[[n userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
keyboardRect = [self.view convertRect:keyboardRect fromView:nil];
CGFloat keyboardTop = keyboardRect.origin.y;
// Resize scroll view
CGRect newScrollViewFrame = CGRectMake(0, 0, self.view.bounds.size.width, keyboardTop);
newScrollViewFrame.size.height = keyboardTop - self.view.bounds.origin.y;
[self.scrollView setFrame:newScrollViewFrame];
}
Run Code Online (Sandbox Code Playgroud)
我注意到我的十进制键盘的keyboardRect是244,默认键盘的键盘是207.我不知道如何解决这个问题.此问题也只在iOS 8中出现.我的应用程序在iOS 7中没有任何问题.感谢您的帮助.
更新:我发现当最初选择文本字段时,滚动视图会相应地移动.当您在键盘启动时选择另一个文本字段时,问题发生时.看来,scrollview将其大小重置为原始尺寸.为什么会这样?有没有办法阻止这种情况发生?
在更新了我的iOS 7代码之后,我遇到了一个让我感到困惑的问题.这段代码在iOS 6中运行良好:
-(void)showPDFFile
{
NSString* fileName = @"Report.PDF";
NSArray *arrayPaths =
NSSearchPathForDirectoriesInDomains(
NSDocumentDirectory,
NSUserDomainMask,
YES);
NSString *path = [arrayPaths objectAtIndex:0];
NSString* pdfFileName = [path stringByAppendingPathComponent:fileName];
CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size;
// This has been set to accomadate iPhone 5 screen size. //
if (iOSDeviceScreenSize.height == 568) {
webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 455)];
}
else{
webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 367)];
}
NSURL *url = [NSURL fileURLWithPath:pdfFileName];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webView setScalesPageToFit:YES]; …Run Code Online (Sandbox Code Playgroud)